Repository navigation
Expand file tree
/
Copy pathcheckdiskheader.asm
More file actions
77 lines (73 loc) · 2.01 KB
/
Copy pathcheckdiskheader.asm
File metadata and controls
77 lines (73 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
; OpenDiskSysROM
; Copyright (c) 2026 Daniel Oranguthang
;
; This program is free software: you can redistribute it and/or modify it under
; the terms of the GNU Lesser General Public License version 3 as published by
; the Free Software Foundation.
;
; This program is distributed in the hope that it will be useful, but WITHOUT
; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
; FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
; details.
;
; You should have received a copy of the GNU Lesser General Public License
; along with this program. If not, see <https://www.gnu.org/licenses/>.
; The disk info block: its mark, the disk ID, and what follows the boot file code.
DISK_MARK_LENGTH EQU 14
DISK_ID_LENGTH EQU 10
DISK_INFO_REST EQU 56 - 1 - DISK_MARK_LENGTH - DISK_ID_LENGTH - 1
; The body of CheckDiskHeader. Reads the whole disk info block (56 bytes with
; its type): the "*NINTENDO-HVC*" mark, the 10-byte disk ID, the boot file
; code, and 30 bytes of manufacturing data this BIOS has no use for.
; Fails with WRONG_SIGNATURE, or with the error of the first ID field that
; differs from the one asked for.
CheckDiskHeaderImpl:
LDA #1
JSR CheckBlockType
LDY #0
@mark:
JSR ReadByte
CMP DiskMark,Y
BNE @badMark
INY
CPY #DISK_MARK_LENGTH
BNE @mark
LDY #0
@id:
JSR ReadByte
STA DISK_TEMP
LDA (DISK_PTR1),Y
CMP #$FF ; $FF matches anything
BEQ @next
CMP DISK_TEMP
BNE @badId
@next:
INY
CPY #DISK_ID_LENGTH
BNE @id
JSR ReadByte
STA DISK_BOOT_CODE
LDY #DISK_INFO_REST
@rest:
JSR ReadByte
DEY
BNE @rest
JMP EndOfBlockRead
@badMark:
LDA #WRONG_SIGNATURE
JMP DiskExit
@badId:
LDA DiskIdErrors,Y
JMP DiskExit
DiskMark:
DB "*NINTENDO-HVC*"
; The error for each byte of the disk ID: licensee, game name and type (4),
; version, side, disk number, disk type, and one more byte.
DiskIdErrors:
DB WRONG_MAKER_ID
DB WRONG_GAME, WRONG_GAME, WRONG_GAME, WRONG_GAME
DB WRONG_GAME_VER
DB WRONG_SIDE_NUM
DB WRONG_DISK_NUM
DB WRONG_ADDL_DISK_ID1
DB WRONG_ADDL_DISK_ID2