Skip to content

Commit

Permalink
fix (&title-load): MAG file with a header of less than 32 bytes are n…
Browse files Browse the repository at this point in the history
…ot loaded
  • Loading branch information
kg68k committed Jun 19, 2024
1 parent 59fa8fa commit a1169a4
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 41 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 4.2.2 (2024-06-19)

* `&title-load`でヘッダが32バイト未満のMAGファイルを表示できない不具合を修正。


# 4.2.1 (2024-06-12)

* マクロ定義の先頭が空白+`\`のとき、行の連結にならない不具合を修正。
Expand Down
2 changes: 1 addition & 1 deletion src/include/version.mac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

* mint version number ------------------------- *

mint_version: .reg '4.2.1'
mint_version: .reg '4.2.2'
minthis_ver: .reg '3.10'


Expand Down
73 changes: 33 additions & 40 deletions src/titleload.s
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@

* Constant ------------------------------------ *

MAG_MAX: .equ 1024<<16+1024
MIT_MAX: .equ (1024-8)<<16+(512-4)
MAG_XY_MAX: .equ 1024<<16+1024
MIT_XY_MAX: .equ (1024-8)<<16+(512-4)

COL_MIT_4: .equ -2
COL_MIT_16: .equ -1
Expand Down Expand Up @@ -240,6 +240,18 @@ option_l_y:
bra option_check_tail

_error: bra error
_error2: bra error2

Read4Bytes:
lea (~flag_buf,a5),a0 ;バッファを流用
subq.l #4,d5 ;ファイルの残りバイト数
pea (4) ;読み込みバイト数
pea (a0)
move d7,-(sp)
DOS _READ
addq.l #10-4,sp
cmp.l (sp)+,d0 ;ccrZ=1なら4バイト読み込めた
rts

option_check_tail:
tst.b (a0)+
Expand All @@ -265,45 +277,26 @@ no_arg:
bmi _error2
move.l d0,d5 ;ファイルサイズ

lea (~flag_buf,a5),a0 ;流用
moveq #32,d1 ;チェックデータ+作者名を読む
move.l d1,-(sp)
pea (a0)
move d7,-(sp)
DOS _READ
addq.l #10-4,sp
cmp.l (sp)+,d0
bne _error2

move.l #MAG_MAX,d6
lea (a0),a1 ;画像形式の判別
cmpi.l #'MAKI',(a1)+
bne @f
cmpi.l #'02 ',(a1)+
beq skip_comment ;MAKI02
@@: move.l (a0),d0
subi.l #'HK03',d0
subq.l #1,d0
bhi _error2 ;未対応の形式

move.l #MIT_MAX,d6
subq.b #1,d0 ;'HK03' -> -2
move.b d0,(~color_mode,a5) ;'HK04' -> -1

moveq #4,d1 ;ヘッダ直後にシーク
clr -(sp)
move.l d1,-(sp)
move d7,-(sp)
DOS _SEEK
addq.l #8,sp
tst.l d0
bpl skip_comment

_error2: bra error2

;チェックデータを読んで画像形式を判別する
bsr Read4Bytes
bne _error2
cmpi.l #'MAKI',(a0)
bne @f
bsr Read4Bytes
bne _error2
cmpi.l #'02 ',(a0)
bne _error2 ;未対応のMAKI系形式
move.l #MAG_XY_MAX,(~max_xy,a5) ;MAKI02 (.MAG)
bra skip_comment
@@:
move.l (a0),d0
subi.l #'HK03',d0 ;HK03 -> 0, HK04 -> 1
subq.l #1,d0 ;HK03 -> -1, HK04 -> 0
bhi _error2 ;未対応の形式
subq.b #1,d0 ;HK03 -> -2, HK04 -> -1
move.b d0,(~color_mode,a5)
move.l #MIT_XY_MAX,(~max_xy,a5)
skip_comment:
move.l d6,(~max_xy,a5)
sub.l d1,d5
moveq #EOF,d1
skip_comment_loop:
move d7,-(sp) ;コメントを読み捨てる
Expand Down

0 comments on commit a1169a4

Please sign in to comment.