ROM Disassembly

See all articles from SINCUS v5 n1

Here’s a nice example of why we’d want to allow two computers to communicate via their RS-232 ports.( See “Can We Talk?”, page 20 in this issue. By configuring stream #3, as an RS-232 port, a disassembler (Devpak 3, in this case) was used to “PRINT” a disassembly of the entire Home ROM to a nonexistent printer.

In place of the printer, at the other end of the RS-232 cable, was an IBM PC, which took in all the data and wrote it to a disk file. (It ended up with about 300K of text.) Since the PC has some very powerful file handling and editing capabilities, it’s fairly easy to “pretty up” the listing with comments and blank lines, and to do other necessary housekeeping chores. (This is an ongoing job; it’s far from done.)

I’ve added comments that I think will be useful, and a lot more helpful information can be found in “The Complete Spectrum ROM Disassembly”, by Dr. Ian Logan And Frank O’Hara, published by Melbourne House. My disassembly is annotated under the assumption that you’ll have a copy of their book handy.

Whenever possible, the program is broken up at the same spots it’s broken in the Spectrum Disassembly, and if the routine is similar or identical to the Spectrum version, it’s so mentioned, and the Spectrum address given. This will aid you in looking up Logan and O’Hara’s comments, which describe each routine in rich detail. I’ve pointed out all places where the TS2068 code differs and these at least are thoroughly commented. Between this and the Spectrum Disassembly, you should get a reasonably complete picture of what is happening.

Although I’ve tried to make it as easy as possible to compare this to Logan and O’Hara’s work, there’s one scheme where a change seemed worthwhile. Whenever a system variable is accessed as a displacement from the IY register, they substitute the system variable name. I’ve chosen to retain the original form of the instruction and put the system variable name in the comment field. This way, if you have routines that change the IY register, you can readily see whether or not you have to change it back before calling a particular ROM routine.

We don’t know how much interest there will be in this. It can be expanded (or eliminated!) depending on your response. Please let us know what you think.

At present, SINCUS NEWS gets “first crack” at publishing the disassembly, so it wouldn’t be appropriate to honor requests for large portions not yet published here. But if you have questions regarding a particular routine, feel free to let me know, and I may be able to supply small portions of unpublished code. Right now, I’ll have to limit such help to dues paying members of SINCUS, as I’m not sure what the response will be. In the meantime, I hope you’ll find these listings useful.

(Ed note: Again much thanks Wes for your continuing help in authoring such a wealth of information. The disassembly is printed in the centerfold so you can remove [no staples please] and three hole punch or as necessary to keep this jewel of info together. To the readers, Wes is now writing for Time Designs Magazine, and is tackling the bank switching theory of the TS2068.)

;###########################################################
;# TS2068 ROM Disassembly #
;###########################################################

;Start here, for Power-On, or RESET
; Identical to Spectrum at 0000

0000 F3 DI
0001 AF XOR A ;Flags a "power up"
0002 11FFFF LD DE,#FFFF ;Highest RAM to check
0005 C3310D JP #0D31 ;Continue power up

;Here for RST 08. Put up an error message
; Identical to Spectrum at 0008

0008 2A5D5C LD HL,(CH_ADD) ;Save present character address
000B 225F5C LD (X_PTR),HL ; before processing the error
000E 1843 JR L0053 ;Continue error processing

;Here for RST 10. Print Character in A
; Identical to Spectrum at 0010

0010 C3ED11 JP #11ED
0013 FFFFFFFF DEFB #FF,#FF,#FF,#FF
0017 FF DEFB #FF

;Here for RST 18. Collect present BASIC character in A
; Identical to Spectrum at 0018

0018 2A5D5C LD HL,(CH_ADD)
001B 7E LD A,(HL)

001C CD7D00 L001C CALL #007D ;Check if it's printable
001F D0 RET NC ;If it is

;Here for RST 20. Collect NEXT BASIC character in A
; Identical to Spectrum at 0020

0020 CD7400 CALL #0074 ;Update CH_ADD & get character
0023 18F7 JR L001C
0025 FFFFFF DEFB #FF,#FF,#FF

;Here for RST 28. Run Floating Point Calculator
; Identical to Spectrum at 0028

0028 C31A37 JP #371A ;To the calculator
002B FFFFFF DEFB #FF,#FF,#FF
002E FFFF DEFB #FF,#FF

;Here for RST 30. Allocate BC locations in the workspace
; Identical to Spectrum at 0030

0030 C5 PUSH BC
0031 2A615C LD HL,(WORKSP)
0034 E5 PUSH HL
0035 C32D13 JP #132D ;Open space

;Here to process the interrupt. Scans the keyboard &
; updates FRAMES every 1/60 second
; Identical to Spectrum at 0038

0038 F5 PUSH AF
0039 E5 PUSH HL
003A 2A785C LD HL,(FRAMES)
003D 23 INC HL
003E 22785C LD (FRAMES),HL ;Update low 2 bytes of FRAMES
0041 7C LD A,H
0042 B5 OR L
0043 2003 JR NZ,L0048
0045 FD3440 INC (IY+64) ;FRAMES+2 - Update third byte
0048 C5 L0048 PUSH BC
0049 D5 PUSH DE
004A CDE102 CALL #02E1 ;Read keyboard
004D D1 POP DE
004E C1 POP BC
004F E1 POP HL
0050 F1 L0050 POP AF
0051 FB EI
0052 C9 RET

;Continuation of the error routine at 0008
; Identical to Spectrum at 0053

0053 E1 L0053 POP HL
0054 6E LD L,(HL)

0055 FD7500 LD (IY+0),L ;ERR_NR
0058 ED7B3D5C LD SP,(ERR_SP) ;Normally ends up with #0EBD from the
; last stack item
005C C35413 JP #1354 ;Continue error processing
005F FFFFFFFF DEFB #FF,#FF,#FF,#FF
0063 FFFFFF DEFB #FF,#FF,#FF

;Process an NMI. Bug at 006D makes this useless
; Identical to Spectrum at 0066

0066 F5 PUSH AF
0067 E5 PUSH HL
0068 2AB05C LD HL,(#5CB0)
006B 7C LD A,H
006C B5 OR L
006D 2001 JR NZ,L0070 ;Should be JR Z,
006F E9 JP (HL)

0070 E1 L0070 POP HL
0071 F1 POP AF
0072 ED45 RETN

;Increment CH_ADD and retrieve the character it points to
; Identical to Spectrum at 0074

0074 2A5D5C LD HL,(CH_ADD)
0077 23 INC HL
0078 225D5C LD (CH_ADD),HL
007B 7E LD A,(HL)
007C C9 RET

;See if character in A is printable. One or more spaces
; are skipped, if not
; SIMILAR to Spectrum at 007D

007D FE21 CP "!"
007F D0 RET NC
0080 FE0D CP #0D ;ENTER
0082 C8 RET Z
0083 FE0C CP #0C ;DELETE
0085 C8 RET Z
0086 FE10 CP #10 ;INK control (lowest control character)
0088 D8 RET C
0089 FE18 CP #18 ;i greater than TAB control
008B 3F CCF
008C D8 RET C
008D 23 INC HL ;Skip over an extra space for each
; control character
008E FE16 CP #16
0090 3801 JR C,L0093
0092 23 INC HL ;Skip one more for AT & TAB

0093 37 L0093 SCF
0094 225D5C LD (CH_ADD),HL
0097 C9 RET

;################################
;# KEYBOARD SECTION #
;################################

;The "Tokens" Table
; SIMILAR to Spectrum at 0095

0098 BF DEFB #BF
0099 524EC4 DEFB "RN","D"+#80 ;RND
009C 494E4B45 DEFB "INKEY","$"+#80 ;INKEY$
00A0 59A4
00A2 50C9 DEFB "P","I"+#80 ;PI
00A4 46CE DEFB "F","N"+#80 ;FN
00A6 504F494E DEFB "POIN","T"+#80 ;POINT
00AA D4
00AB 53435245 DEFB "SCREEN","$"+#80 ;SCREEN$
00AF 454EA4
00B2 415454D2 DEFB "ATT","R"+#80 ;ATTR
00B6 41D4 DEFB "A","T"+#80 ;AT
00B8 5441C2 DEFB "TA","B"+#80 ;TAB
00BB 56414CA4 DEFB "VAL","$"+#80 ;VAL$
00BF 434F44C5 DEFB "COD","E"+#80 ;CODE
00C3 5641CC DEFB "VA","L"+#80 ;VAL
00C6 4C45CE DEFB "LE","N"+#80 ;LEN
00C9 5349CE DEFB "SI","N"+#80 ;SIN
00CC 434FD3 DEFB "CO","S"+#80 ;COS
00CF 5441CE DEFB "TA","N"+#80 ;TAN
00D2 4153CE DEFB "AS","N"+#80 ;ASN
00D5 4143D3 DEFB "AC","S"+#80 ;ACS
00D8 4154CE DEFB "AT","N"+#80 ;ATN
00DB 4CCE DEFB "L","N"+#80 ;LN
00DD 4558D0 DEFB "EX","P"+#80 ;EXP
00E0 494ED4 DEFB "IN","T"+#80 ;INT
00E3 5351D2 DEFB "SQ","R"+#80 ;SQR
00E6 5347CE DEFB "SG","N"+#80 ;SGN
00E9 4142D3 DEFB "AB","S"+#80 ;ABS
00EC 504545CB DEFB "PEE","K"+#80 ;PEEK
00F0 49CE DEFB "I","N"+#80 ;IN
00F2 5553D2 DEFB "US","R"+#80 ;USR
00F5 535452A4 DEFB "STR","$"+#80 ;STR$
00F9 434852A4 DEFB "CHR","$"+#80 ;CHR$
00FD 4E4FD4 DEFB "NO","T"+#80 ;NOT
0100 4249CE DEFB "BI","N"+#80 ;BIN
0103 4FD2 DEFB "O","R"+#80 ;OR
0105 414EC4 DEFB "AN","D"+#80 ;AND
0108 3CBD DEFB "<","="+#80 ;<=
010A 3EBD DEFB ">","="+#80 ;>=
010C 3CBE DEFB "<",">"+#80 ;<>
010E 4C494EC5 DEFB "LIN","E"+#80 ;LINE
0112 544845CE DEFB "THE","N"+#80 ;THEN
0116 54CF DEFB "T","O"+#80 ;TO
0118 535445D0 DEFB "STE","P"+#80 ;STEP
011C 44454620 DEFB "DEF F","N"+#80 ;DEF FN
0120 46CE
0122 4341D4 DEFB "CA","T"+#80 ;CAT
0125 464F524D DEFB "FORMA","T"+#80 ;FORMAT
0129 41D4
012B 4D4F56C5 DEFB "MOV","E"+#80 ;MOVE
012F 45524153 DEFB "ERAS","E"+#80 ;ERASE
0133 C5
0134 4F50454E DEFB "OPEN ","#"+#80 ;OPEN #
0138 20A3
013A 434C4F53 DEFB "CLOSE ","#"+#80 ;CLOSE #
013E 4520A3
0141 4D455247 DEFB "MERG","E"+#80 ;MERGE
0145 C5
0146 56455249 DEFB "VERIF","Y"+#80 ;VERIFY
014A 46D9
014C 424545D0 DEFB "BEE","P"+#80 ;BEEP
0150 43495243 DEFB "CIRCL","E"+#80 ;CIRCLE
0154 4CC5
0156 494ECB DEFB "IN","K"+#80 ;INK
0159 50415045 DEFB "PAPE","R"+#80 ;PAPER
015D D2
015E 464C4153 DEFB "FLAS","H"+#80 ;FLASH
0162 C8
0163 42524947 DEFB "BRIGH","T"+#80 ;BRIGHT
0167 48D4
0169 494E5645 DEFB "INVERS","E"+#80 ;INVERSE
016D 5253C5
0170 4F5645D2 DEFB "OVE","R"+#80 ;OVER
0174 4F55D4 DEFB "OU","T"+#80 ;OUT
0177 4C505249 DEFB "LPRIN","T"+#80 ;LPRINT
017B 4ED4
017D 4C4C4953 DEFB "LLIS","T"+#80 ;LLIST
0181 D4
0182 53544FD0 DEFB "STO","P"+#80 ;STOP
0186 524541C4 DEFB "REA","D"+#80 ;READ
018A 444154C1 DEFB "DAT","A"+#80 ;DATA
018E 52455354 DEFB "RESTOR","E"+#80 ;RESTORE
0192 4F52C5
0195 4E45D7 DEFB "NE","W"+#80 ;NEW
0198 424F5244 DEFB "BORDE","R"+#80 ;BORDER
019C 45D2
019E 434F4E54 DEFB "CONTINU","E"+#80 ;CONTINUE
01A2 494E55C5
01A6 4449CD DEFB "DI","M"+#80 ;DIM
01A9 5245CD DEFB "RE","M"+#80 ;REM
01AC 464FD2 DEFB "FO","R"+#80 ;FOR
01AF 474F2054 DEFB "GO T","O"+#80 ;GO TO
01B3 CF
01B4 474F2053 DEFB "GO SU","B"+#80 ;GO SUB
01B8 55C2
01BA 494E5055 DEFB "INPU","T"+#80 ;INPUT
01BE D4
01BF 4C4F41C4 DEFB "LOA","D"+#80 ;LOAD
01C3 4C4953D4 DEFB "LIS","T"+#80 ;LIST
01C7 4C45D4 DEFB "LE","T"+#80 ;LET
01CA 50415553 DEFB "PAUS","E"+#80 ;PAUSE
01CE C5
01CF 4E4558D4 DEFB "NEX","T"+#80 ;NEXT
01D3 504F4BC5 DEFB "POK","E"+#80 ;POKE
01D7 5052494E DEFB "PRIN","T"+#80 ;PRINT
01DB D4
01DC 504C4FD4 DEFB "PLO","T"+#80 ;PLOT
01E0 5255CE DEFB "RU","N"+#80 ;RUN
01E3 534156C5 DEFB "SAV","E"+#80 ;SAVE
01E7 52414E44 DEFB "RANDOMIZ","E"+#80 ;RANDOMIZE
01EB 4F4D495A
01EF C5
01F0 49C6 DEFB "I","F"+#80 ;IF
01F2 434CD3 DEFB "CL","S"+#80 ;CLS
01F5 445241D7 DEFB "DRA","W"+#80 ;DRAW
01F9 434C4541 DEFB "CLEA","R"+#80 ;CLEAR
01FD D2
01FE 52455455 DEFB "RETUR","N"+#80 ;RETURN
0202 52CE
0204 434F50D9 DEFB "COP","Y"+#80 ;COPY
0208 44454C45 DEFB "DELET","E"+#80 ;DELETE
020C 54C5
020E 4F4E2045 DEFB "ON ER","R"+#80 ;ON ERR
0212 52D2
0214 53544943 DEFB "STIC","K"+#80 ;STICK
0218 CB
0219 534F554E DEFB "SOUN","D"+#80 ;SOUND
021D C4
021E 465245C5 DEFB "FRE","E"+#80 ;FREE
0222 52455345 DEFB "RESE","T"+#80 ;RESET
0226 D4

;The Keyboard Data Tables. Used to convert a keypress
; to an actual ASCII character or token
;Identical to Spectrum at 0205

;The Character Table

0227 42485936 DEFB "BHY6"
022B 35544756 DEFB "5TGV"
022F 4E4A5537 DEFB "NJU7"
0233 34524643 DEFB "4RFC"
0237 4D4B4938 DEFB "MKI8"
023B 33454458 DEFB "3EDX"
023F 0E4C4F39 DEFB #0E,"LO9"
0243 3257535A DEFB "2WSZ"
0247 200D5030 DEFB " ",#0D,"PO"
024B 315141 DEFB "1QA"

;E mode, No Shift

024E E3C4E0E4 DEFB #E3,#C4,#E0,#E4 ;READ,BIN,LPRINT,DATA
0252 B4BCBDBB DEFB #B4,#BC,#BD,#BB ;TAN,SGN,ABS,SQR
0256 AFB0B1C0 DEFB #AF,#B0,#B1,#C0 ;CODE,VAL,LEN,USR
025A A7A6BEAD DEFB #A7,#A6,#BE,#AD ;PI,INKEY$,PEEK,TAB
025E B2BAE5A5 DEFB #B2,#BA,#E5,#A5 ;SIN,INT,RESTORE,RND
0262 C2E1B3B9 DEFB #C2,#E1,#B3,#B9 ;CHR$,LLIST,COS,EXP
0266 C1B8 DEFB #C1,#B8 ;STR$,LN

;E mode, Shift Pressed

0268 7EDCDA5C DEFB #7E,#DC,#DA,#5C ;FREE,BRIGHT,PAPER,
026C B77B7DD8 DEFB #B7,#7B,#7D,#D8 ;ATN,ONERR,SOUND,CIRCLE
0270 BFAEAAAB DEFB #BF,#AE,#AA,#AB ;IN,VAL$,SCREEN$,ATTR
0274 DDDEDF7F DEFB #DD,#DE,#DF,#7F ;INVERSE,OVER,OUT,RESET
0278 B5D67CD5 DEFB #B5,#D6,#7C,#D5 ;ASN,VERIFY,STICK,MERGE
027C 5DDBB6D9 DEFB #5D,#DB,#B6,#D9 ;],FLASH,ACS,INK
0280 5BD7 DEFB #5B,#D7 ;[,BEEP

;Caps Shift & Number key

0282 0C070604 DEFB #0C,#07,#06,#04 ;DELETE,EDIT,CAPS LOCK,TRUE VIDEO
0286 05080A0B DEFB #05,#08,#0A,#0B ;INV VIDEO,c left,c down,c up
028A 090F DEFB #09,#0F ;c right, GRAPHICS

;Symbol Shift & Letter Key

028C E22A3FCD DEFB #E2,#2A,#3F,#CD ;STOP,*,?,STEP

0294 AC2D2B3D DEFB #AC,#2D,#2B,#3D ;AT,-,+,=
0298 2E2C3B22 DEFB #2E,#2C,#3B,#22 ;. , ; "
029C C73CC33E DEFB #C7,#3C,#C3,#3E ;<=,<,NOT,>
02A0 C52FC960 DEFB #C5,#2F,#C9,#60 ;OR,/,<>,
02A4 C63A DEFB #C6,#3A ;AND,:


;E mode, Symbol Shift, & Number Key

02A6 D0CEA8CA DEFB #D0,#CE,#A8,#CA ;FORMAT,DEF FN,FN,LINE
02AA D3D4D1D2 DEFB #D3,#D4,#D1,#D2 ;OPEN#,CLOSE#,MOVE,ERASE
02AE A9CF DEFB #A9,#CF ;POINT,CAT


;Keyboard Scanning Routine
; Identical to Spectrum at 028E

02B0 2E2F LD L,#2F
02B2 11FFFF LD DE,#FFFF
02B5 01FEFE LD BC,#FEFE

;Loop 8 times - once for each five keys
02B8 ED78 L02B8 IN A,(C)
02BA 2F CPL
02BB E61F AND #1F
02BD 280E JR Z,L02CD ;If none of these 5 are being pressed

02BF 67 LD H,A
02C0 7D LD A,L

02C1 14 L02C1 INC D
02C2 C0 RET NZ ;If the dummy at the keyboard is
; holding down too many keys

;Keep subtracting 8 until we find a keypress
02C3 D608 L02C3 SUB #08
02C5 CB3C SRL H
02C7 30FA JR NC,L02C3

02C9 53 LD D,E
02CA 5F LD E,A ;Save older keypress
02CB 20F4 JR NZ,L02C1 ;If more than one key pressed

02CD 2D L02CD DEC L
02CE CB00 RLC B ;Update counter
02D0 38E6 JR C,L02B8 ;If all 8 loops not done

;Handle all allowable multiple keypresses
02D2 7A LD A,D
02D3 3C INC A
02D4 C8 RET Z
02D5 FE28 CP #28
02D7 C8 RET Z
02D8 FE19 CP #19
02DA C8 RET Z
02DB 7B LD A,E
02DC 5A LD E,D
02DD 57 LD D,A
02DE FE18 CP #18
02E0 C9 RET

;Main Keyboard Routine. CALLed by Interrupt Handler
; Almost Identical To Spectrum At 02BF

02E1 CDB002 CALL #02B0 ;Keyboard scan
02E4 C0 RET NZ

02E5 21005C LD HL,K_STATE

02E8 CB7E L02E8 BIT 7,(HL)
02EA 2007 JR NZ,L02F3
02EC 23 INC HL
02ED 35 DEC (HL)
02EE 2B DEC HL
02EF 2002 JR NZ,L02F3

02F1 36FF LD (HL),#FF

02F3 7D L02F3 LD A,L
02F4 21045C LD HL,K_STATE + 4
02F7 BD CP L
02F8 20EE JR NZ,L02E8

02FA CD5C03 CALL #035C ;Get value of key being pressed
02FD D0 RET NC

02FE FDCB30AE RES 5,(IY+48) ;FLAGS2 - Reset repeat of DELETE key
0302 21005C LD HL,K_STATE
0305 BE CP (HL)
0306 282E JR Z,L0336

0308 EB EX DE,HL
0309 21045C LD HL,K_STATE + 4
030C BE CP (HL)
030D 2827 JR Z,L0336

030F CB7E BIT 7,(HL)
0311 2004 JR NZ,L0317

0313 EB EX DE,HL
0314 CB7E BIT 7,(HL)
0316 C8 RET Z

0317 5F L0317 LD E,A
0318 77 LD (HL),A
0319 23 INC HL
031A 3605 LD (HL),#05
031C 23 INC HL
031D 3A095C LD A,(REPDEL)
0320 77 LD (HL),A
0321 23 INC HL
0322 FD4E07 LD C,(IY+7)
0325 FD5601 LD D,(IY+1)
0328 E5 PUSH HL
0329 CD7103 CALL #0371 ;Decode keys
032C E1 POP HL
032D 77 LD (HL),A

032E 32085C L032E LD (LAST_K),A
0331 FDCB01EE SET 5,(IY+1)
0335 C9 RET

;Key Repeater
; SIMILAR to Spectrum at 0310

0336 23 L0336 INC HL
0337 3605 LD (HL),#05
0339 23 INC HL
033A 3A085C LD A,(LAST_K) ;New
033D FECE CP #CE ;New
033F D0 RET NC ;New

0340 35 DEC (HL)
0341 C0 RET NZ

0342 3A0A5C LD A,(REPPER)
0345 77 LD (HL),A
0346 23 INC HL
0347 7E LD A,(HL)
0348 FE0C CP #0C
034A 20E2 JR NZ,L032E
034C FDCB30EE SET 5,(IY+48)
0350 F5 PUSH AF
0351 01204E LD BC,#4E20

0354 0B L0354 DEC BC
0355 79 LD A,C
0356 B0 OR B
0357 20FB JR NZ,L0354

0359 F1 POP AF
035A 18D2 JR L032E

;Returns With The Value of The Key Being Pressed, Unless
; It's Only A Shift Key
; Identical to Spectrum At 031E

035C 42 LD B,D
035D 1600 LD D,#00
035F 7B LD A,E
0360 FE27 CP #27
0362 D0 RET NC

0363 FE18 CP #18
0365 2003 JR NZ,L036A
0367 CB78 BIT 7,B
0369 C0 RET NZ

036A 212702 L036A LD HL,#0227
036D 19 ADD HL,DE
036E 7E LD A,(HL)
036F 37 SCF
0370 C9 RET

;Key Decoder - Produces "real" code from keyscan info
; Identical to Spectrum at 0333

0371 7B LD A,E
0372 FE3A CP #3A
0374 382F JR C,L03A5

0376 0D DEC C
0377 FA8D03 JP M,#038D

037A 2803 JR Z,L037F

037C C64F ADD A,#4F
037E C9 RET

037F 210D02 L037F LD HL,#020D
0382 04 INC B
0383 2803 JR Z,L0388

0385 212702 LD HL,#0227

0388 1600 L0388 LD D,#00
038A 19 ADD HL,DE
038B 7E LD A,(HL)
038C C9 RET

038D 214B02 LD HL,#024B
0390 CB40 BIT 0,B
0392 28F4 JR Z,L0388

0394 CB5A BIT 3,D
0396 280A JR Z,L03A2


0398 FDCB305E BIT 3,(IY+48)
039C C0 RET NZ
039D 04 INC B
039E C0 RET NZ

039F C620 ADD A,#20
03A1 C9 RET

03A2 C6A5 L03A2 ADD A,#A5
03A4 C9 RET

03A5 FE30 L03A5 CP #30
03A7 D8 RET C

03A8 0D DEC C
03A9 FADB03 JP M,#03DB

03AC 2019 JR NZ,L03C7

03AE 217602 LD HL,#0276
03B1 CB68 BIT 5,B
03B3 28D3 JR Z,L0388

03B5 FE38 CP #38
03B7 3007 JR NC,L03C0

03B9 D620 SUB #20
03BB 04 INC B
03BC C8 RET Z

03BD C608 ADD A,#08
03BF C9 RET

03C0 D636 L03C0 SUB #36
03C2 04 INC B
03C3 C8 RET Z

03C4 C6FE ADD A,#FE
03C6 C9 RET

03C7 215202 L03C7 LD HL,#0252
03CA FE39 CP #39
03CC 28BA JR Z,L0388

03CE FE30 CP #30
03D0 28B6 JR Z,L0388

03D2 E607 AND #07
03D4 C680 ADD A,#80
03D6 04 INC B
03D7 C8 RET Z

03D8 EE0F XOR #0F
03DA C9 RET

03DB 04 INC B
03DC C8 RET Z

03DD CB68 BIT 5,B
03DF 215202 LD HL,#0252
03E2 20A4 JR NZ,L0388

03E4 D610 SUB #10
03E6 FE22 CP #22
03E8 2806 JR Z,L03F0

03EA FE20 CP #20
03EC C0 RET NZ

03ED 3E5F LD A,#5F
03EF C9 RET

03F0 3E40 L03F0 LD A,#40
03F2 C9 RET