Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ROM0:20DA 7B ld a,e ; Load LSB of destination bank into E
- ROM0:20DB EA 97 D0 ld (d097),a ; Load A into WRA1:D097
- ROM0:20DE 7A ld a,d ; Load MSB of destination bank into D
- ROM0:20DF EA 98 D0 ld (d098),a ; Load A into WRA1:D098
- ROM0:20E2 7E ld a,(hl) ; Read command
- ROM0:20E3 FE FF cp a,ff ; If the command is 0xFF (end stream)
- ROM0:20E5 C8 ret z ; Return to the caller
- ROM0:20E6 E6 E0 and a,e0 ; Test for an extended command (0x00-0xFE)
- ROM0:20E8 FE E0 cp a,e0 ; Is this an extended command?
- ROM0:20EA 20 10 jr nz,20fc ; If it isn't, go to 20FC
- ; 0xE0-0xFE Command (ExtCommand)
- ; Multiplies a command up to 32 times.
- ROM0:20EC 7E ld a,(hl) ; Read byte, do not increment ROM pointer
- ROM0:20ED 87 add a ; ?
- ROM0:20EE 87 add a ; ?
- ROM0:20EF 87 add a ; ?
- ROM0:20F0 E6 E0 and a,e0 ; Get only the number of bytes
- ROM0:20F2 F5 push af ; Save AF
- ROM0:20F3 2A ldi a,(hl) ; Read byte, increment ROM pointer
- ROM0:20F4 E6 03 and a,03 ; Keep only the last three bytes
- ROM0:20F6 47 ld b,a ; Set B to this number
- ROM0:20F7 2A ldi a,(hl) ; Read byte, increment ROM pointer
- ROM0:20F8 4F ld c,a ; Load C with byte read
- ROM0:20F9 03 inc bc ; Add one to the number of bytes
- ROM0:20FA 18 08 jr 2104 ; Continue inside ParseFirstOrderCommand
- ; ParseFirstOrderCommand
- ; Parses first-order commands and passes second-order commands to
- ; ParseSecondOrderCommmand.
- ROM0:20FC F5 push af ; Save AF
- ROM0:20FD 2A ldi a,(hl) ; Read byte, increment ROM pointer
- ROM0:20FE E6 1F and a,1f ; Get only the number of bytes
- ROM0:2100 4F ld c,a ; Load number of bytes into C
- ROM0:2101 06 00 ld b,00 ; Load B with 0
- ROM0:2103 0C inc c ; Increment C (?)
- ROM0:2104 04 inc b ; Increment B (?)
- ROM0:2105 0C inc c ; Increment C (?)
- ROM0:2106 F1 pop af ; Restore AF
- ROM0:2107 CB 7F bit 7,a ; 2nd-order command (> 80)?
- ROM0:2109 20 49 jr nz,2154 ; If so go to 2154, else
- ROM0:210B FE 20 cp a,20 ; Check if command = 0x20
- ROM0:210D 28 15 jr z,2124 ; Go to 0x20 processor at 2124, else
- ROM0:210F FE 40 cp a,40 ; Check if command = 0x40
- ROM0:2111 28 1E jr z,2131 ; Go to 0x40 processor at 2131, else
- ROM0:2113 FE 60 cp a,60 ; Check if command = 0x60
- ROM0:2115 28 2F jr z,2146 ; Go to 0x60 processor at 2146, else
- ; 0x00-0x1F Command (ByteCopy)
- ;
- ; Directly copies (# + 1) bytes.
- ROM0:2117 0D dec c ; Decrement C
- ROM0:2118 20 04 jr nz,211e ; If C != 0 then go to 211E
- ROM0:211A 05 dec b ; Decrement B
- ROM0:211B CA E2 20 jp z,20e2 If B = 0 return to 20E2 ("Read command")
- ROM0:211E 2A ldi a,(hl) ; Read byte, increment ROM pointer
- ROM0:211F CD 99 D0 call d099 ; Call RAM write routine
- ROM0:2122 18 F3 jr 2117 ; Jump back to 2117
- ; 0x20-0x3F Command (ByteFill)
- ;
- ; Fills (# + 1) bytes with next byte's value.
- ROM0:2124 2A ldi a,(hl) ; Read byte, increment ROM pointer
- ROM0:2125 0D dec c ; Decrement C
- ROM0:2126 20 04 jr nz,212c ; If C != 0 then go to 212C
- ROM0:2128 05 dec b ; Decrement B
- ROM0:2129 CA E2 20 jp z,20e2 ; If B = 0 return to 20E2 ("Read command")
- ROM0:212C CD 99 D0 call d099 ; Call RAM write routine
- ROM0:212F 18 F4 jr 2125 ; Jump back to 2125
- ; 0x40-0x5F Command (WordFill)
- ;
- ; Fills (# + 1) words with next word's value.
- ROM0:2131 0D dec c ; Decrement C
- ROM0:2132 20 04 jr nz,2138 ; If C != 0 then go to 2138
- ROM0:2134 05 dec b ; Decrement B
- ROM0:2135 CA 42 21 jp z,2142 ; If B = 0 go to 2142
- ROM0:2138 2A ldi a,(hl) ; Read byte, increment ROM pointer
- ROM0:2139 CD 99 D0 call d099 ; Call RAM write routine
- ROM0:213C 3A ldd a,(hl) ; Read byte, decrement ROM pointer
- ROM0:213D CD 99 D0 call d099 ; Call RAM write routine
- ROM0:2140 18 EF jr 2131 ; Jump back to 2131
- ROM0:2142 23 inc hl ; Increment ROM pointer by one word
- ROM0:2143 23 inc hl
- ROM0:2144 18 9C jr 20e2 ; return to 20E2 ("Read command")
- ; 0x60-0x7F Command (IncrementalFill)
- ;
- ; Fills (# + 1) bytes with starting byte + an incrementing value.
- ROM0:2146 2A ldi a,(hl) ; Read byte, increment ROM pointer
- ROM0:2147 0D dec c ; Decrement C
- ROM0:2148 20 04 jr nz,214e ; If C != 0 then go to 214E
- ROM0:214A 05 dec b ; Decrement B
- ROM0:214B CA E2 20 jp z,20e2 ; If B = 0 return to 20E2 ("Read command")
- ROM0:214E CD 99 D0 call d099 ; Call RAM write routine
- ROM0:2151 3C inc a ; Increment A
- ROM0:2152 18 F3 jr 2147 ; Jump back to 2147
- ; ParseSecondOrderCommmand
- ; Parses second-order commands.
- ROM0:2154 E5 push hl ; Save HL
- ROM0:2155 F5 push af ; Save AF
- ROM0:2156 2A ldi a,(hl) ; Read byte, increment ROM pointer
- ROM0:2157 6E ld l,(hl) ; Read byte into low ROM pointer
- ROM0:2158 67 ld h,a ; Load high ROM pointer into A
- ROM0:2159 FA 97 D0 ld a,(d097) ; Save A to D097
- ROM0:215C 85 add l ; Add/subtract A to low ROM pointer
- ROM0:215D 6F ld l,a ; Load low ROM pointer into A
- ROM0:215E FA 98 D0 ld a,(d098) ; Save A to D098
- ROM0:2161 8C adc h ; add A with carry to high ROM pointer
- ROM0:2162 67 ld h,a ; load high ROM pointer into A
- ROM0:2163 F1 pop af ; Restore AF
- ROM0:2164 FE 80 cp a,80 ; Check if command = 0x80
- ROM0:2166 28 08 jr z,2170 ; Go to 0x80 processor at 2170, else
- ROM0:2168 FE A0 cp a,a0 ; Check if command = 0xA0
- ROM0:216A 28 0F jr z,217b ; Go to 0xA0 processor at 217B, else
- ROM0:216C FE C0 cp a,c0 ; Check if command = 0xC0
- ROM0:216E 28 23 jr z,2193 ; Go to 0xC0 processor at 2193
- ; 0x80-0x9F (MemoryCopy)
- ;
- ; Copies (# + 1) bytes from the address provided in the next two bytes.
- ROM0:2170 0D dec c ; Decrement C
- ROM0:2171 20 03 jr nz,2176 ; If C != 0 then go to 2176
- ROM0:2173 05 dec b ; Decrement B
- ROM0:2174 28 29 jr z,219f ; If B = 0 go to 219F
- ROM0:2176 2A ldi a,(hl) ; Read byte, increment ROM pointer
- ROM0:2177 12 ld (de),a ; Load DE with A
- ROM0:2178 13 inc de ; Increment DE
- ROM0:2179 18 F5 jr 2170 ; Jump back to 2170
- ; 0xA0-0xBF: (MemoryCopyEOR)
- ;
- ; Copies (# + 1) bytes from the address provided in the next two bytes,
- ; and EORs the data with 0xFF
- ROM0:217B 0D dec c ; Decrement C
- ROM0:217C 20 04 jr nz,2182 ; If C != 0 then go to 2182
- ROM0:217E 05 dec b ; Decrement B
- ROM0:217F CA 9F 21 jp z,219f ; If B = 0 go to 219F
- ROM0:2182 2A ldi a,(hl) ; Read byte, increment ROM pointer
- ROM0:2183 C5 push bc ; Save BC
- ROM0:2184 01 08 00 ld bc,0008 ; Number of times to rotate
- ROM0:2187 1F rra ; Rotate A right
- ROM0:2188 CB 10 rl b ; Rotate B left
- ROM0:218A 0D dec c ; Decrement C
- ROM0:218B 20 FA jr nz,2187 ; If C != 0 then go to 2187
- ROM0:218D 78 ld a,b ; Load A with B
- ROM0:218E C1 pop bc ; Restore BC
- ROM0:218F 12 ld (de),a ; Write A to destination
- ROM0:2190 13 inc de ; Incrememnt destination pointer
- ROM0:2191 18 E8 jr 217b ; Jump back to 217B
- ; 0xC0-0xDF (ReverseCopy)
- ;
- ; Copies (# + 1) bytes in reverse order from the address provided.
- ROM0:2193 0D dec c ; Decrement C
- ROM0:2194 20 04 jr nz,219a ; If C != 0 then go to 219A
- ROM0:2196 05 dec b ; Decrement B
- ROM0:2197 CA 9F 21 jp z,219f ; If B = 0 go to 219F
- ROM0:219A 3A ldd a,(hl) ; Read byte, decrement ROM pointer
- ROM0:219B 12 ld (de),a ; Write A to destination
- ROM0:219C 13 inc de ; Incrememnt destination pointer
- ROM0:219D 18 F4 jr 2193 ; Jump back to 2193
- ; Exit ParseSecondOrderCommmand
- ROM0:219F E1 pop hl ; restore ROM pointer
- ROM0:21A0 23 inc hl ; Increment ROM pointer by one word
- ROM0:21A1 23 inc hl
- ROM0:21A2 C3 E2 20 jp 20e2 ; Return to 20E2 ("Read command")
- ; RAM Copy Routine
- ;
- ; Written into RAM at D099-D09F at startup.
- ; Responsible for writing bytes to RAM at destination (DE).
- ; A is the byte to write.
- ; DE is the destination address.
- WRA1:D099 00 nop ; Padding
- WRA1:D09A 00 nop ; Padding
- WRA1:D09B 12 ld (de),a ; Write A to destination
- WRA1:D09C 00 nop ; Padding
- WRA1:D09D 00 nop ; Padding
- WRA1:D09E 13 inc de ; Incrememnt destination pointer
- WRA1:D09F C9 ret ; Return to caller
Add Comment
Please, Sign In to add comment