Kapooka - homebrew logic game

Talk about programming of homebrew games only.
User avatar
MADrigal
Site Admin
Posts: 1189
Joined: Sun Sep 15, 2013 1:00 pm
Contact:

Re: Kapooka - homebrew logic game

Post by MADrigal » Wed Jan 13, 2010 9:35 am

mr_bogus wrote:I wish there was a way to directly PEEK/POKE the character memory referenced by the screen, rather than using an array + plot. This would speed up many games, and the ability to read the screen's character memory would simplify extra array (or in the case of Kapooka, finding a contiguous block of memory by trial and error, then using this to store the level).

I will try putting in sound next chance I get, my main concern is slowing down the game. However the 2nd book of programs mentions a POKE command to start/stop a sound, so that may be an idea, running other instructions/s between, rather than freezing everything while the "SOUND" command plays.
Well, as Carlsson just reported, it's possibile to "link" to locations in VRAM, but the problem is that it would be too slow, since you can't address directly to VRAM, but you must do that via more poke's in a row.

Since the problem with CV BASIC is slowness (execution time is the same for each instruction, regardless of its complexity) 1xPLOT command is faster than 3xPOKE commands, and it's more "optimized" since it does all the VRAM addressing, LDA and STA via assembler.

The posts by Carlsson are *VERY* interesting!

@ Carlsson: CvEmu2 allows you to save "state", including VRAM data and registers. You can also peek into its source code, and see the structure of save state. I remember I temporarily added VRAM data saving in a FunnyMu private build, which I used to understand the way BASIC programs are stored by CV BASIC (needed for the instant load/save routines).
User avatar
carlsson
Posts: 507
Joined: Fri Jun 13, 2008 7:39 am
Location: Västerås, Sweden

Re: Kapooka - homebrew logic game

Post by carlsson » Wed Jan 13, 2010 11:27 am

Ok, I'll see if I pursue deeper into this. Ideally I want to get started with machine code programming anyway.

Here is another program that doesn't work. First time it seems to hang the emulator. On second attempt you get a graphical screen of garbage:

10 PLOT10,1,33
15 POKE12289,10 : REM VDP_Status_Write
16 POKE12289,0 : REM MSB = $00
17 PRINTPEEK(8192) : REM VDP_Data_Read

The garbage may not be so strange, since Basic runs inside the VDP and we change the register inside the program run by an interpretator which probably also wants to change the very same register. I suppose there is no other Basic function which is controlled by a pointer. It could be worth disassembling Basic though to find out if e.g. one can redirect the location where RND, INT, LOG or other numerical function fetches its data. The RND function is tied with PEEK(3) but it doesn't help us.
User avatar
mr_bogus
Posts: 24
Joined: Fri Jun 13, 2008 8:40 am

Re: Kapooka - homebrew logic game

Post by mr_bogus » Wed Jan 13, 2010 12:07 pm

Very interesting post! I have been reading http://bifi.msxnet.org/msxnet/tech/tms9918a.txt linked from your "Memory Maps, chip documentation" thread...

Seems to need to use both $3001 (twice in a row without the register resetting) to set the address to read/write, and then $3000 for the value. Perhaps the flag on port #1 is being reset between the calls, eg. by BASIC reading port #1 or reading/writing port #0? Is there any knowledge of when (or how often) BASIC accesses these registers?
User avatar
MADrigal
Site Admin
Posts: 1189
Joined: Sun Sep 15, 2013 1:00 pm
Contact:

Re: Kapooka - homebrew logic game

Post by MADrigal » Wed Jan 13, 2010 12:09 pm

carlsson wrote:Ok, I'll see if I pursue deeper into this. Ideally I want to get started with machine code programming anyway.

Here is another program that doesn't work. First time it seems to hang the emulator. On second attempt you get a graphical screen of garbage:

10 PLOT10,1,33
15 POKE12289,10 : REM VDP_Status_Write
16 POKE12289,0 : REM MSB = $00
17 PRINTPEEK(8192) : REM VDP_Data_Read

The garbage may not be so strange, since Basic runs inside the VDP and we change the register inside the program run by an interpretator which probably also wants to change the very same register. I suppose there is no other Basic function which is controlled by a pointer. It could be worth disassembling Basic though to find out if e.g. one can redirect the location where RND, INT, LOG or other numerical function fetches its data. The RND function is tied with PEEK(3) but it doesn't help us.
@ Carlsson: I wish you didn't really execute the ": REM ..." commands on the BASIC, since 1 only command is allowed per each line. ;)

I also executed it, and the emulator only displays an exclamation mark on row 1 of the screen then freezes. I tried that with all BASIC versions, all the same result except the speed-hacked" BASIC clears screen soon after displaying the exclamation mark. No "garbage" at all.

Useful functions to add to the BASIC interpreter would be "VPOKE" and "VPEEK" to manage the VRAM.

Since the TMS9928 is also used in TI-99 and MSX, maybe there's similar functions in those computer BASIC's interpreters, which can be grabbed and included in the CV BASIC. Just an idea.
User avatar
carlsson
Posts: 507
Joined: Fri Jun 13, 2008 7:39 am
Location: Västerås, Sweden

Re: Kapooka - homebrew logic game

Post by carlsson » Wed Jan 13, 2010 12:23 pm

Eh.. yes, the REM were added for your clarity, not intended to be typed in. As for making a CV Extended Basic, I'm sure we could extend it on our own. I also thought about VPEEK, which pretty much is what my ASM routine above would do but limiting the call to within the default video matrix. Ideally one should be able to VPEEK the whole VDP RAM area.

If you press F3 in FunnyMu, it resets with the program intact. Run it again, and you get garbage.

Mr Bogus: I also checked that document, but I find the TI VDP Programmer's Guide more visually pleasing. Since the only hosting found on the AtariAge forum was a Rapidshare page, I decided to upload it to my own web space as well:

http://www.cbm.sfks.se/files/TI-VDP-PRG.pdf (about 2.5 MB)
User avatar
MADrigal
Site Admin
Posts: 1189
Joined: Sun Sep 15, 2013 1:00 pm
Contact:

Re: Kapooka - homebrew logic game

Post by MADrigal » Wed Jan 13, 2010 12:28 pm

@ Carlsson: oh man, what a great document! A complete guide to VDP programming wow, by TI wow! :shock:

I ran the program 2-3 times in a row, of course, but never saw any garbage.
User avatar
carlsson
Posts: 507
Joined: Fri Jun 13, 2008 7:39 am
Location: Västerås, Sweden

Re: Kapooka - homebrew logic game

Post by carlsson » Wed Jan 13, 2010 1:14 pm

carlsson wrote:It could be worth disassembling Basic
Poor man's disassembler is to load the Basic BIN/ROM file into another emulator, e.g. VICE x64. That way at least I can follow part of the 6502 code even if I barely has a clue what various BIOS calls will do. Of course a poor man could load the BIOS as a file too, but that will have to wait until later. Generally I'm a big fan of Recomment, a Perl script best run in a *nix environment. It generates source code very close to the DASM format, and is decent on separating instructions from data areas.
User avatar
mr_bogus
Posts: 24
Joined: Fri Jun 13, 2008 8:40 am

Re: Kapooka - homebrew logic game

Post by mr_bogus » Wed Jan 13, 2010 1:38 pm

carlsson wrote:...but I find the TI VDP Programmer's Guide more visually pleasing. Since the only hosting found on the AtariAge forum was a Rapidshare page, I decided to upload it to my own web space as well:

http://www.cbm.sfks.se/files/TI-VDP-PRG.pdf (about 2.5 MB)
WOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOW!!
That document is amazing :shock: :D
User avatar
carlsson
Posts: 507
Joined: Fri Jun 13, 2008 7:39 am
Location: Västerås, Sweden

Re: Kapooka - homebrew logic game

Post by carlsson » Tue Jan 19, 2010 9:49 am

In case all your answers were not covered by the Programmer's Reference Guide, the same AtariAge thread lists a datasheet which is even more detailed. Perhaps a bit too detailed for us who are new to programming the VDP, but one never knows when you get curious about the gritty details:
http://emu-docs.org/VDP%20TMS9918/Datas ... MS9918.pdf
User avatar
MADrigal
Site Admin
Posts: 1189
Joined: Sun Sep 15, 2013 1:00 pm
Contact:

Re: Kapooka - homebrew logic game

Post by MADrigal » Tue Jan 19, 2010 11:18 am

I found a disassembly of the BIOS, made by Roberto Ventura back in 2001.

Not sure if it helps, but it probably does.

Code: Select all

ROM ADDRESSES:
--------------

f800-f807       zero
f808-f84a       cartridge startup handler (bffc)        [VDP...]
f84b-f856       call                                    [VDP (game) setup]
f857-f85b       data (VDP starting mode data)           []
f85c-f85e   FillSC                                      [fill screen with $FF ->$FD9E]
f861-f87f       splash screen message                   []
f880-f9ff       splash screen charset                                 []
fa00-fac6       BIOS function (call)                    [PIA]
fac7-fad2       data?                                   []
fad3-fae7       code?                                   [...]
fae8-fafa       code?                                   [...]
fafb-fb0f       code?                                   [...]
fb10-fb15       code?                                   [...]
fb16-fb22       call?                                   [...]
fb23-fb48       code?                                   [...]
fb49-fb55       call                                    [...]
fb56-fbd5       data?                                   []
fbd6-fbdc       BIOS function                           []
fbde-fc78       code?                                   [!!!]
fc79-fcfb       data?                                   []
fcfc-fd09       code?                                   [VDP...
fd0a-fd22       BIOS function                           [...]
fd23-fd2b       code?                                   [VDP...]
fd2c-fd34       BIOS function "DEX" (call fd33)         [...]
fd35-fd3d       "DEY"                                   [...]
fd3e-fd44       "ASLA"                                  [...]
fd45-fd4b       "LSRA"                                  [...]
fd4c            db $ff                                  []
fd4d-fd81       BIOS function                           [VDP]
fd53-fd81*      call                                    [VDP]
fd7c-fd81*      call                                    [...]
fd82-fd85       BIOS function (call)                    [VDP #0]
fd86-fdc3       BIOS function                           [VDP]
fd9e-fdc3*      BIOS function (call)                    [VDP]
fda6-fdc3*      call                                    [VDP]
fdc4-fdd6       call                                    [VDP]
fdc8-fdd6*      BIOS function (call)                    [VDP]
fdd3-fdd6*      BIOS function (call)                    [VDP #1]
fdd7-fdeb       code?                                   [...]
fdec-fdfe       BIOS function (call)                    [...]
fdff-fe08       call                                    [...]
fe09-fe12       BIOS function (via jump)                [VDP via fdc4]
fe0f-fe12*      call                                    [VDP]
fe13-fe1e       code?                                   [VDP via...]
fe1f-fe2b       BIOS function (call)                    [VDP regwrite]
fe2c-fe2d       IRQ (indirect jump to handler)          [(bffe)]
fe2f-fe37       call                                    [clear zeropage]
fe38-fe53       BIOS function (call)                    [VDP]
fe54-fe62       BIOS function (call)                    [silence PSG]
fe63-fe66       data                                    []
fe67-fe76       call                                    [PIA: select PSG out]
fe77-fe82       BIOS function (call)                    [PIA reg write]
fe83-fec4       BIOS function                           [VDP...]
fec5-fee3       BIOS function (call)                    [...]
fee4-fef8       call                                    [VDP...]
fee8-fef8*      call                                    [VDP...]
feef-fef8*      call                                    [...]
fef9-ff09       BIOS function                           [VDP...]
ff0a-ff2d       call                                    [VDP...]
ff24-ff2d*      call                                    [...]
ff2e-ff3e       BIOS function                           [VDP...]
ff3f-ff51       built in IRQ handler                    [VDP,PIA...]
ff52-ff57       BIOS function - IRQ return              [...]
ff58-ff65       BIOS function (call)                    [...]
ff66-ffa0       reset code                              [PIA & VDP setup]
ffa1-ffc2       BIOS function                           [VDP...]
ffba-ffc2       call                                    [VDP]
ffc3-ffdf       string...                               []
ffe0-ffea       BIOS function                           [VDP...]
ffeb-fff9       padding?                                []
fffa-ffff       vectors (NMI,RESET,IRQ)                 []

BIOS DISASSEMBLY:
-----------------

0000f000: ZERO

[CARTRIDGE STARTUP HANDLER]

0000F808: F0 3E         beq $0000F848   ;Z flag...vedi ff66
;
0000F80A: A9 D1         lda #$D1        ;setup some VDP regs
0000F80C: 48		pha
0000F80D: A2 05         ldx #$05        ;very cool, eh?
0000F80F: BD 56 F8	lda $F856,x
0000F812: 20 1F FE      jsr SETVDP      ;Set VDP mode
0000F815: CA		dex
0000F816: 10 F7		bpl $0000F80F
;
0000F818: A9 61         lda #$61        ;address f861
0000F81A: A2 F8		ldx #$F8
0000F81C: 20 53 FD      jsr $FD53       ;Display "CREATIVISION c198"
0000F81F: 68		pla
0000F820: 20 82 FD      jsr $FD82       ;(*) 3000=A
0000F823: A9 F1		lda #$F1
0000F825: A2 07		ldx #$07
0000F827: 20 1F FE      jsr $FE1F       ;(*) IRQ OFF, 3001=A, 3001=X^0x80
0000F82A: A9 00		lda #$00
0000F82C: A2 D8		ldx #$D8
0000F82E: 20 1F FE      jsr $FE1F       ;(*) IRQ OFF, 3001=A, 3001=X^0x80
0000F831: A0 1F		ldy #$1F
0000F833: A9 F1		lda #$F1
;
0000F835: 20 82 FD      jsr $FD82       ;(*) 3000=A
0000F838: 88		dey
0000F839: 10 FA		bpl $0000F835
;
0000F83B: 20 33 FD      jsr $FD33       ;(*) "fD2c" dex*1
0000F83E: D0 FB		bne $0000F83B
0000F840: 88		dey
0000F841: D0 F8		bne $0000F83B
;
0000F843: 20 4B F8      jsr $F84B       ;(*) call fe1f 7 times (bff7..bff0)
0000F846: EA		nop
0000F847: EA		nop
0000F848: 6C E8 BF      jmp ($BFE8)     ;CARTRIDGE ENTRY CODE

[CALL]                                  ;[*] call fe1f 7 times (bff7..bff0)

0000F84B: A2 07         ldx #$07        ;loop, index, param (bff7..bff0)
0000F84D: BD F0 BF	lda $BFF0,x
0000F850: 20 1F FE      jsr $FE1F       ;(*) IRQ OFF, 3001=A, 3001=X^0x80
0000F853: CA		dex
0000F854: 10 F7		bpl $0000F84D
0000F856: 60            rts     ;VDP #0 ;cool eh?

[DATA]                  ;splasf screen VDP regs

0000F857: C0                    ;VDP #1 16k RAM, display mode: graphics 1
0000F858: 04                    ;VDP #2 Name Table $1000-$12FF
0000F859: 60                    ;VDP #3 Colour Table $1800-$13BF
0000F85A: 00                    ;VDP #4 Pattern Table $0000-$07FF (Character Set)
0000F85B: 10                    ;VDP #5 Sprite Table $0800-$0FFF

[CALL]

0000F85C: A2 FF         ldx #$FF
0000F85E: 4C 9E FD	jmp $FD9E

[DATA]                  ;

0000F861: C8 00  01			;message parameters
*000F864: D0
0000F865: D1 2F  06
*000F868: DB                            ;should be CV logo!
*000F869: DC
0000F86A: C0
0000F86B: C0
0000F86C: C0
*000F86D: FF
0000F86E: D1 4C  08
*000F871: DD                            ;should be CV logo!
*000F872: DE
*000F873: DF
*000F874: E0
*000F875: FB
*000F876: FC
*000F877: FD
*000F878: FE
0000F879: D2 18  04
0000F87C: DA                            ;(c)
0000F87D: D1                            ;1
0000F87E: D9                            ;9
0000F87F: D8                            ;8

         (00)                           ;cool eh? first charline gfx=00

[CHARSET (f880-f9ff)]

[BIOS FUNCTION (CALL)]

0000FA00: A9 00         lda #$00        ;0000 0000 (select ddr register)
0000FA02: 8D 01 10      sta $1001       ;crA: ddr selected
0000FA05: 8D 03 10      sta $1003       ;crB: ddr selected
0000FA08: 8D 02 10      sta $1002       ;ddrB: all input line
0000FA0B: A9 0F         lda #$0F        ;0000 1111
0000FA0D: 8D 00 10      sta $1000       ;ddrA: input(HI)/output(LO) line
0000FA10: A9 04         lda #$04        ;0000 0100 (select I/O buffer)
0000FA12: 8D 01 10      sta $1001       ;crA: I/O buffer selected
0000FA15: 8D 03 10      sta $1003       ;crB: I/O buffer selected
;;;;;;;;;
0000FA18: A9 F7         lda #$F7        ;mask:  1b) 11110111 1a) 11111011
0000FA1A: A2 03         ldx #$03        ;       19) 11111101 18) 11111110
0000FA1C: 8D 00 10      sta $1000       ;ioA: output
0000FA1F: 48		pha
0000FA20: AD 02 10      lda $1002       ;ioB: input
0000FA23: 49 FF         eor #$FF        ;not
0000FA25: 95 18         sta $18,x       ;$1b..$18
0000FA27: 68            pla             ;>update mask
0000FA28: 38            sec             ;>
0000FA29: 6A            ror a           ;>
0000FA2A: CA		dex
0000FA2B: 10 EF         bpl $0000FA1C   ;loop (4)
0000FA2D: 8D 00 10      sta $1000       ;last mask: 11111111
0000FA30: 20 67 FE      jsr $FE67       ;(*) ddr: B output (PSG) [default]
;;;;;;;;;
0000FA33: A2 03		ldx #$03
0000FA35: 8A            txa             ;>X odd: ($00)=$fbb2 Y=$0f [15..0]
0000FA36: 0A            asl a           ;>X even:($00)=$fbc2 Y=$13 [19..0]
0000FA37: 29 02         and #$02        ;>
0000FA39: A8            tay             ;>
0000FA3A: B9 AA FB      lda $FBAA,y     ;>
0000FA3D: 85 00         sta $00         ;>
0000FA3F: B9 AB FB      lda $FBAB,y     ;>
0000FA42: 85 01         sta $01         ;>
0000FA44: BC AE FB      ldy $FBAE,x     ;>
0000FA47: B5 18         lda $18,x       ;input $1b..$18
0000FA49: 0A            asl a           ;input*2 (discard hi bit)
0000FA4A: F0 12         beq $0000FA5E   ;HW input is "NULL" X1111111b ?
;
0000FA4C: D1 00         cmp ($00),y     ;search input in ODD or EVEN table
0000FA4E: F0 05         beq $0000FA55   ;found
0000FA50: 88		dey
0000FA51: 10 F9         bpl $0000FA4C   ;no match: next elem 
0000FA53: 30 0B         bmi $0000FA60   ;not found,branch however
;
0000FA55: 98            tya             ;elem found, get table entry 
0000FA56: 09 80         ora #$80        ;set bit 7
0000FA58: B4 11		ldy $11,x
0000FA5A: F0 02         beq $0000FA5E   ;same as previous?
0000FA5C: 49 C0         eor #$C0        ;not bit 7,6
0000FA5E: 95 11         sta $11,x       ;translated input
;
0000FA60: CA		dex
0000FA61: 10 D2         bpl $0000FA35   ;loop (4)
;;;;;;;;;
0000FA63: A9 00		lda #$00
0000FA65: 85 10		sta $10
0000FA67: 85 1D		sta $1D
0000FA69: A2 03		ldx #$03
0000FA6B: B5 18         lda $18,x       ;input $1b..$18
0000FA6D: 0A            asl a           ;read MSB
0000FA6E: 26 15         rol $15         ;accumulate new input MSBs dcbaDCBA
0000FA70: 29 FF         and #$FF        ;HW input is "NULL" X1111111b ?
0000FA72: F0 04		beq $0000FA78
;
0000FA74: 86 1E         stx $1E         ;save last non "NULL" input
0000FA76: E6 1D         inc $1D         ;count non "NULL" inputs
;
0000FA78: CA		dex
0000FA79: 10 F0         bpl $0000FA6B   ;loop (4)
;;;;;;;;;
0000FA7B: A5 15         lda $15         ;>read input MSBs dcbaDCBA
0000FA7D: 4A            lsr a           ;>get old MSBs 0000dcba
0000FA7E: 4A            lsr a           ;>
0000FA7F: 4A            lsr a           ;>
0000FA80: 4A            lsr a           ;>
0000FA81: 49 0F         eor #$0F        ;>not old MSBs
0000FA83: 25 15         and $15         ;>A= dcba && DCBA (MSBs:old && new)
0000FA85: 20 49 FB      jsr $FB49       ;(*) accumulate bits...$16 $17
0000FA88: A5 15		lda $15
0000FA8A: 20 49 FB      jsr $FB49       ;(*) accumulate bits...$16 $17
;;;;;;;;;
0000FA8D: A0 01		ldy #$01
0000FA8F: A2 05		ldx #$05
0000FA91: A9 04		lda #$04
0000FA93: 24 15		bit $15
0000FA95: F0 04		beq $0000FA9B
;
0000FA97: 86 1E		stx $1E
0000FA99: E6 1D		inc $1D
;
0000FA9B: 0A		asl a
0000FA9C: CA		dex
0000FA9D: 88		dey
0000FA9E: 10 F3		bpl $0000FA93
;;;;;;;;;
0000FAA0: A5 1D		lda $1D
0000FAA2: D0 03		bne $0000FAA7
0000FAA4: 85 1C		sta $1C
0000FAA6: 60		rts
;-------;
0000FAA7: A5 1C		lda $1C
0000FAA9: C9 02		cmp #$02
0000FAAB: B0 03		bcs $0000FAB0
0000FAAD: E6 1C		inc $1C
0000FAAF: 60		rts
;-------;
0000FAB0: F0 01		beq $0000FAB3
0000FAB2: 60		rts
;-------;
0000FAB3: E6 1C		inc $1C
0000FAB5: C6 1D		dec $1D
0000FAB7: F0 01		beq $0000FABA
0000FAB9: 60		rts
;-------;
0000FABA: A5 1E		lda $1E
0000FABC: 0A		asl a
0000FABD: AA		tax
0000FABE: BD C8 FA	lda $FAC8,x
0000FAC1: 48		pha
0000FAC2: BD C7 FA	lda $FAC7,x
0000FAC5: 48		pha
0000FAC6: 60		rts

[DATA?]

0000FAC7: D3		.db $D3		; <Invalid OPcode>
0000FAC8: FA		.db $FA		; <Invalid OPcode>
0000FAC9: E8		inx
0000FACA: FA		.db $FA		; <Invalid OPcode>
0000FACB: EE FA FB	inc $FBFA
0000FACE: FA		.db $FA		; <Invalid OPcode>
0000FACF: 02		.db $02		; <Invalid OPcode>
0000FAD0: FB		.db $FB		; <Invalid OPcode>
0000FAD1: 10 FB		bpl $0000FACE

[CODE?]

0000FAD3: EA            nop
0000FAD4: A5 18         lda $18
0000FAD6: 0A		asl a
0000FAD7: C9 18         cmp #$18
0000FAD9: D0 0C		bne $0000FAE7
0000FADB: A2 B1		ldx #$B1
0000FADD: A9 02		lda #$02
0000FADF: 24 15		bit $15
0000FAE1: F0 02		beq $0000FAE5
0000FAE3: A2 A1		ldx #$A1
0000FAE5: 86 10		stx $10
0000FAE7: 60		rts

[CODE?]

0000FAE8: EA		nop
0000FAE9: A5 19		lda $19
0000FAEB: 0A		asl a
0000FAEC: D0 28		bne $0000FB16
0000FAEE: EA		nop
0000FAEF: A5 1A		lda $1A
0000FAF1: 0A		asl a
0000FAF2: C9 18		cmp #$18
0000FAF4: D0 04		bne $0000FAFA
0000FAF6: A2 A0		ldx #$A0
0000FAF8: 86 10		stx $10
0000FAFA: 60		rts

[CODE?]

0000FAFB: EA		nop
0000FAFC: A5 1B		lda $1B
0000FAFE: 38		sec
0000FAFF: 2A		rol a
0000FB00: D0 14		bne $0000FB16
0000FB02: EA		nop
0000FB03: A2 AD		ldx #$AD
0000FB05: A9 02		lda #$02
0000FB07: 24 15		bit $15
0000FB09: F0 02		beq $0000FB0D
0000FB0B: A2 BD		ldx #$BD
0000FB0D: 86 10		stx $10
0000FB0F: 60		rts

[CODE?]

0000FB10: EA		nop
0000FB11: A2 88		ldx #$88
0000FB13: 86 10		stx $10
0000FB15: 60		rts

[CALL?]

0000FB16: A2 30		ldx #$30
0000FB18: 49 FE		eor #$FE
0000FB1A: DD 79 FB	cmp $FB79,x
0000FB1D: F0 04		beq $0000FB23
0000FB1F: CA		dex
0000FB20: 10 F8		bpl $0000FB1A
0000FB22: 60		rts

[CODE?]

0000FB23: 8A		txa
0000FB24: 29 0F		and #$0F
0000FB26: 85 10		sta $10
0000FB28: 8A		txa
0000FB29: A2 06		ldx #$06
0000FB2B: DD 56 FB	cmp $FB56,x
0000FB2E: B0 03		bcs $0000FB33
0000FB30: CA		dex
0000FB31: 10 F8		bpl $0000FB2B
0000FB33: 8A		txa
0000FB34: 0A		asl a
0000FB35: 0A		asl a
0000FB36: 85 1D		sta $1D
0000FB38: A5 15		lda $15
0000FB3A: 29 03		and #$03
0000FB3C: 49 03		eor #$03
0000FB3E: 05 1D		ora $1D
0000FB40: AA		tax
0000FB41: BD 5D FB	lda $FB5D,x
0000FB44: 05 10		ora $10
0000FB46: 85 10		sta $10
0000FB48: 60		rts

[CALL]

0000FB49: 4A            lsr a           ;$16= accumulate bits 0 and 1
0000FB4A: 26 16		rol $16
0000FB4C: 4A		lsr a
0000FB4D: 26 16		rol $16
0000FB4F: 4A		lsr a
0000FB50: 26 17         rol $17         ;$17= accumulate bits 2 and 3
0000FB52: 4A		lsr a
0000FB53: 26 17		rol $17
0000FB55: 60		rts

[DATA]

0000FB56: 00				;TABLE - Shift selection
0000FB57: 01 0C
0000FB59: 10 20
0000FB5B: 2D 30 
0000FB5D: C0 C0				;TABLE - High nibble (half byte)
0000FB5F: B0 B0
0000FB61: A0 A0
0000FB63: B0 B0
0000FB65: B0 B0
0000FB67: A0 A0
0000FB69: 80 C0
0000FB6B: 80 C0
0000FB6D: 90 D0
0000FB6F: 90 D0
0000FB71: 80 80
0000FB73: 80 80
0000FB75: 95 95
0000FB77: 95 95

0000FB79: DB			;TABLE - KEYS, JOYSTICKS
0000FB7A: 00
0000FB7B: 9E
0000FB7C: 3E AE 6E
0000FB7F: 5E F3 7B
0000FB82: BB
0000FB83: EB
0000FB84: CF
0000FB85: AF
0000FB86: 00
0000FB87: 3F
0000FB88: 9F
0000FB89: 00
0000FB8A: DC
0000FB8B: F2
0000FB8C: BA
0000FB8D: 7C
0000FB8E: D6 F8
0000FB90: F4
0000FB91: 77
0000FB92: 7D B7 D7
0000FB95: E7
0000FB96: 6F
0000FB97: 5F
0000FB98: BD DD CE
0000FB9B: B6 BC
0000FB9D: 76 F9
0000FB9F: 7A
0000FBA0: E6 DA
0000FBA2: F5 EA
0000FBA4: 00
0000FBA5: 00
0000FBA6: ED 00 00
0000FBA9: EC

[DATA]

0000FBAA: B2 FB         "even table pointer" fbb2
0000FBAC: C2 FB         "odd  table pointer" fbc2

0000FBAE: 0F 13 0F 13   even table is $10 bytes, odd table is $14 bytes

["EVEN TABLE"]          ;compare data (table=input*2)

                        ;joy:   FxLxURDx    
0000FBB2: 84            ;42      ?   RD         right down
0000FBB3: 04            ;02           D         down
0000FBB4: 06            ;03           D?        down
0000FBB5: 0E            ;07          RD?        right down
0000FBB6: 0A            ;05          R ?        right
0000FBB7: 08            ;04          R          right
0000FBB8: 88            ;44      ?  R           right
0000FBB9: 98            ;4c      ?  UR          up right
0000FBBA: 90            ;48      ?  U           up
0000FBBB: 10            ;08         U           up
0000FBBC: 30            ;18        ?U           up
0000FBBD: 70            ;38       L?U           up left
0000FBBE: 60            ;30       L?            left
0000FBBF: 40            ;20       L             left
0000FBC0: C0            ;60      ?L             left
0000FBC1: C4            ;62      ?L   D         left down

["ODD TABLE"]           ;compare data (table=input*2)
;`
0000FBC2: 14            ;0a     00001010        Z       :
0000FBC3: 22            ;11     00010001        A       P
0000FBC4: 30            ;18     00011000        Q       ;
0000FBC5: 60            ;30     00110000        2       /
0000FBC6: 24            ;12     00010010        X       0
0000FBC7: 42            ;21     00100001        S       O
0000FBC8: 18            ;0c     00001100        W       L
0000FBC9: C0            ;60     01100000        3       .
0000FBCA: 44            ;22     00100010        C       9
0000FBCB: 82            ;41     01000001        D       I
0000FBCC: 28            ;14     00010100        E       K
0000FBCD: 50            ;28     00101000        4       ,
0000FBCE: 84            ;42     01000010        V       8
0000FBCF: 06            ;03     00000011        F       U
0000FBD0: 48            ;24     00100100        R       J
0000FBD1: 90            ;48     01001000        5       M
0000FBD2: 0C            ;06     00000110        B       7
0000FBD3: 0A            ;05     00000101        G       Y
0000FBD4: 88            ;44     01000100        T       H
0000FBD5: A0            ;50     01010000        6       N
                        ;09     00010001

[BIOS FUNCTION]

0000FBD6: A9 D5         lda #$D5	;Not used by Basic - to $FC72 (SOUND?)
0000F8D8: A0 FC         ldy #$FC
0000FBDA: 85 04		sta $04
0000FBDC: 84 05		sty $05

[CODE?]

0000FBDE: 08		php
0000FBDF: 78		sei
0000FBE0: BD 00 BF	lda $BF00,x
0000FBE3: 85 00		sta $00
0000FBE5: BD 01 BF	lda $BF01,x
0000FBE8: 85 01		sta $01
0000FBEA: BC 02 BF	ldy $BF02,x
0000FBED: B1 00		lda ($00),y
0000FBEF: 85 0E		sta $0E
0000FBF1: A9 00		lda #$00
0000FBF3: 85 06		sta $06
0000FBF5: 85 07		sta $07
0000FBF7: 85 08		sta $08
0000FBF9: 20 54 FE      jsr $FE54       ;(*)
0000FBFC: A5 0E		lda $0E
0000FBFE: 85 09		sta $09
0000FC00: E9 01		sbc #$01
0000FC02: B0 FC		bcs $0000FC00
0000FC04: C6 09		dec $09
0000FC06: 10 F8		bpl $0000FC00
0000FC08: A9 02		lda #$02
0000FC0A: 85 0A		sta $0A
0000FC0C: A6 0A		ldx $0A
0000FC0E: 8A		txa
0000FC0F: 20 3F FD      jsr $FD3F       ;(*)
0000FC12: 09 80		ora #$80
0000FC14: 85 0B		sta $0B
0000FC16: D6 06		dec $06,x
0000FC18: 10 37		bpl $0000FC51
0000FC1A: 88		dey
0000FC1B: C0 FF		cpy #$FF
0000FC1D: F0 55		beq $0000FC74
0000FC1F: B1 00		lda ($00),y
0000FC21: 29 07		and #$07
0000FC23: AA		tax
0000FC24: BD 79 FC	lda $FC79,x
0000FC27: A6 0A		ldx $0A
0000FC29: 95 06		sta $06,x
0000FC2B: B1 00		lda ($00),y
0000FC2D: 4A		lsr a
0000FC2E: 4A		lsr a
0000FC2F: 4A		lsr a
0000FC30: F0 18		beq $0000FC4A
0000FC32: AA		tax
0000FC33: CA		dex
0000FC34: D0 04		bne $0000FC3A
0000FC36: 88		dey
0000FC37: B1 00		lda ($00),y
0000FC39: AA		tax
0000FC3A: A5 0B		lda $0B
0000FC3C: 1D 80 FC	ora $FC80,x
0000FC3F: 20 77 FE      jsr $FE77       ;(*)
0000FC42: BD AA FC	lda $FCAA,x
0000FC45: 20 77 FE      jsr $FE77       ;(*)
0000FC48: A9 10		lda #$10
0000FC4A: A6 0A		ldx $0A
0000FC4C: 95 18		sta $18,x
0000FC4E: 4C 5F FC      jmp $FC5F
;
0000FC51: B5 06		lda $06,x
0000FC53: 29 07		and #$07
0000FC55: C9 07		cmp #$07
0000FC57: D0 15		bne $0000FC6E
0000FC59: D6 18		dec $18,x
0000FC5B: 10 02		bpl $0000FC5F
0000FC5D: F6 18		inc $18,x
0000FC5F: 98		tya
0000FC60: 48		pha
0000FC61: B4 18		ldy $18,x
0000FC63: B1 04		lda ($04),y
0000FC65: 05 0B		ora $0B
0000FC67: 09 10		ora #$10
0000FC69: 20 77 FE      jsr $FE77       ;(*)
0000FC6C: 68		pla
0000FC6D: A8		tay
0000FC6E: C6 0A		dec $0A
0000FC70: 10 9A		bpl $0000FC0C
0000FC72: 30 88		bmi $0000FBFC

0000FC74: 20 54 FE      jsr $FE54       ;Turn sound off
0000FC77: 28		plp
0000FC78: 60		rts

[DATA]

0000FC79: 07				;to FCE4
0000FC7A: 0F
0000FC7B: 17
0000FC7C: 1F
0000FC7D: 2F		.db $2F		; <Invalid OPcode>
0000FC7E: 3F		.db $3F		; <Invalid OPcode>
0000FC7F: 5F		.db $5F		; <Invalid OPcode>
0000FC80: 7F		.db $7F		; <Invalid OPcode>
0000FC81: 0E 03 0A	asl $0A03
0000FC84: 02		.db $02		; <Invalid OPcode>
0000FC85: 0B		.db $0B		; <Invalid OPcode>
0000FC86: 06 02		asl $02
0000FC88: 0F		.db $0F		; <Invalid OPcode>
0000FC89: 0D 0C 0C	ora $0C0C
0000FC8C: 0D 0F 01	ora $010F
0000FC8F: 05 09		ora $09
0000FC91: 0E 03 09	asl $0903
0000FC94: 0F		.db $0F		; <Invalid OPcode>
0000FC95: 06 0E		asl $0E
0000FC97: 06 0F		asl $0F
0000FC99: 07		.db $07		; <Invalid OPcode>
0000FC9A: 01 0A		ora ($0A,x)
0000FC9C: 04		.db $04		; <Invalid OPcode>
0000FC9D: 0F		.db $0F		; <Invalid OPcode>
0000FC9E: 09 0E		ora #$0E
0000FCA0: 0A		asl a
0000FCA1: 08		php
0000FCA2: 08		php
0000FCA3: 0A		asl a
0000FCA4: 04		.db $04		; <Invalid OPcode>
0000FCA5: 00		brk
0000FCA6: 0B		.db $0B		; <Invalid OPcode>
0000FCA7: 07		.db $07		; <Invalid OPcode>
0000FCA8: 03		.db $03		; <Invalid OPcode>
0000FCA9: 0F		.db $0F		; <Invalid OPcode>
0000FCAA: 0C		.db $0C		; <Invalid OPcode>
0000FCAB: 1D 1C 1A	ora $1A1C,x
0000FCAE: 19 17 16	ora $1617,y
0000FCB1: 15 13		ora $13,x
0000FCB3: 12		.db $12		; <Invalid OPcode>
0000FCB4: 11 10		ora ($10),y
0000FCB6: 0F		.db $0F		; <Invalid OPcode>
0000FCB7: 0E 0E 0D	asl $0D0E
0000FCBA: 0C		.db $0C		; <Invalid OPcode>
0000FCBB: 0B		.db $0B		; <Invalid OPcode>
0000FCBC: 0B		.db $0B		; <Invalid OPcode>
0000FCBD: 0A		asl a
0000FCBE: 09 09		ora #$09
0000FCC0: 08		php
0000FCC1: 08		php
0000FCC2: 07		.db $07		; <Invalid OPcode>
0000FCC3: 07		.db $07		; <Invalid OPcode>
0000FCC4: 07		.db $07		; <Invalid OPcode>
0000FCC5: 06 06		asl $06
0000FCC7: 05 05		ora $05
0000FCC9: 27		.db $27		; <Invalid OPcode>
0000FCCA: 25 23		and $23
0000FCCC: 21 1F		and ($1F,x)
0000FCCE: 05 05		ora $05
0000FCD0: 04		.db $04		; <Invalid OPcode>
0000FCD1: 04		.db $04		; <Invalid OPcode>
0000FCD2: 04		.db $04		; <Invalid OPcode>
0000FCD3: 03		.db $03		; <Invalid OPcode>
0000FCD4: 03		.db $03		; <Invalid OPcode>
0000FCD5: 0F		.db $0F		; <Invalid OPcode>
0000FCD6: 0F		.db $0F		; <Invalid OPcode>
0000FCD7: 0E 0D 0C	asl $0C0D
0000FCDA: 0B		.db $0B		; <Invalid OPcode>
0000FCDB: 0A		asl a
0000FCDC: 09 08		ora #$08
0000FCDE: 07		.db $07		; <Invalid OPcode>
0000FCDF: 06 05		asl $05
0000FCE1: 04		.db $04		; <Invalid OPcode>
0000FCE2: 03		.db $03		; <Invalid OPcode>
0000FCE3: 02		.db $02		; <Invalid OPcode>
0000FCE4: 01 00		ora ($00,x)
0000FCE6: A9 EB		lda #$EB
0000FCE8: 4C D8 FB	jmp $FBD8
0000FCEB: 0F		.db $0F		; <Invalid OPcode>
0000FCEC: 00				; all 0 to FCFB

[CODE]

0000FCFC: 20 1F FE      jsr $FE1F       ;jsr SETVDP
0000FCFF: A2 E0		ldx #$E0
0000FD01: 20 0F FE      jsr $FE0F       ;jsr RDVRAM (Read Video RAM)
0000FD04: 95 E0		sta $E0,x
0000FD06: E8		inx
0000FD07: D0 F8		bne $0000FD01
0000FD09: 60		rts

[BIOS FUNCTION]

0000FD0A: A8		tay
0000FD0B: 84 07		sty $07
0000FD0D: 85 06		sta $06
0000FD0F: A9 00		lda #$00
0000FD11: A0 07		ldy #$07
0000FD13: 46 06		lsr $06
0000FD15: 90 03		bcc $0000FD1A
0000FD17: 18		clc
0000FD18: 65 07		adc $07
0000FD1A: 6A		ror a
0000FD1B: 66 06		ror $06
0000FD1D: 88		dey
0000FD1E: 10 F5		bpl $0000FD15
0000FD20: 85 07		sta $07
0000FD22: 60		rts

[CODE?]

0000FD23: B1 06		lda ($06),y
0000FD25: 20 82 FD      jsr $FD82       ;jsr WRVRAM (Write Video RAM)
0000FD28: C8		iny
0000FD29: D0 F8		bne $0000FD23
0000FD2B: 60		rts

[BIOS FUNCTION]

0000FD2C: CA		dex		;Decrement X - 1 to 8 times
0000FD2D: CA		dex
0000FD2E: CA		dex
0000FD2F: CA		dex
0000FD30: CA		dex
0000FD31: CA		dex
0000FD32: CA		dex
0000FD33: CA		dex
0000FD34: 60		rts

[]

0000FD35: 88		dey		;Decrement Y - 1 to 8 times
0000FD36: 88		dey
0000FD37: 88		dey
0000FD38: 88		dey
0000FD39: 88		dey
0000FD3A: 88		dey
0000FD3B: 88		dey
0000FD3C: 88		dey
0000FD3D: 60		rts

[]

0000FD3E: 0A		asl a		;Shift A left 1 to 6 times
0000FD3F: 0A		asl a
0000FD40: 0A		asl a
0000FD41: 0A		asl a
0000FD42: 0A		asl a
0000FD43: 0A		asl a
0000FD44: 60		rts

[]

0000FD45: 4A		lsr a		;Shift A right 1 to 6 times
0000FD46: 4A		lsr a
0000FD47: 4A		lsr a
0000FD48: 4A		lsr a
0000FD49: 4A		lsr a
0000FD4A: 4A		lsr a
0000FD4B: 60		rts

0000FD4C: FF		.db $FF

[BIOS FUNCTION]

0000FD4D: AD F8 BF	lda $BFF8
0000FD50: AE F9 BF      ldx $BFF9       ;continues...

[CALL]                  ;PRINT: [VDP #1],[VDP #0],[#bytes],[data],
                        ;       [DVP #1],[VDP #0].[#bytes],[data],
                        ;       ... ... ... ... ... ... ... ...
                        ;       [000000]


0000FD53: 85 09         sta $09         ;write the address in $09
0000FD55: 86 0A		stx $0A
0000FD57: A0 00		ldy #$00
;
0000FD59: B1 09         lda ($09),y     ;read ($09)
0000FD5B: F0 24         beq $0000FD81   ;exit now if ($09)=0
0000FD5D: AA            tax             ;VDP #1
0000FD5E: 20 7C FD      jsr $FD7C       ;(*) next address
0000FD61: B1 09         lda ($09),y     ;VDP #0
0000FD63: 20 1F FE      jsr $FE1F       ;(*) IRQ OFF, 3001=A, 3001=X^0x80
0000FD66: 20 7C FD      jsr $FD7C       ;(*) next address
0000FD69: B1 09         lda ($09),y     ;number of chars
0000FD6B: AA		tax
;
0000FD6C: 20 7C FD      jsr $FD7C       ;(*) next address
0000FD6F: B1 09		lda ($09),y
0000FD71: 20 82 FD      jsr $FD82       ;(*) 3000=A
0000FD74: CA		dex
0000FD75: D0 F5		bne $0000FD6C
;
0000FD77: 20 7C FD      jsr $FD7C       ;(*) next address
0000FD7A: D0 DD         bne $0000FD59   ;loop ; continues...

[CALL]

0000FD7C: C8            iny             ;increment address ($09),Y
0000FD7D: D0 02		bne $0000FD81
0000FD7F: E6 0A		inc $0A
0000FD81: 60		rts

[BIOS FUNCTION (CALL)]                  ;[*] write 3000

0000FD82: 8D 00 30      sta $3000       ;VDP port #0w
0000FD85: 60		rts

[BIOS FUNCTION]

0000FD86: AD FA BF	lda $BFFA
0000FD89: AE FB BF	ldx $BFFB
0000FD8C: 85 06		sta $06
0000FD8E: 86 07		stx $07
0000FD90: A0 00		ldy #$00
0000FD92: B1 06		lda ($06),y
0000FD94: F0 EF		beq $0000FD85
0000FD96: 20 A6 FD      jsr $FDA6       ;(*)
0000FD99: C8		iny
0000FD9A: D0 F6		bne $0000FD92
0000FD9C: A2 BF         ldx #$BF        ;continues...

[BIOS FUNCTION (CALL)]

0000FD9E: A0 00         ldy #$00
0000FDA0: 85 06		sta $06
0000FDA2: 86 07		stx $07
0000FDA4: B1 06         lda ($06),y     ;continues...

[CALL]

0000FDA6: AA		tax
0000FDA7: C8		iny
0000FDA8: B1 06		lda ($06),y
0000FDAA: 20 1F FE      jsr $FE1F       ;(*) IRQ OFF, 3001=A, 3001=X^0x80
0000FDAD: C8		iny
0000FDAE: B1 06		lda ($06),y
0000FDB0: AA		tax
0000FDB1: C8		iny
0000FDB2: B1 06		lda ($06),y
0000FDB4: 85 09		sta $09
0000FDB6: C8		iny
0000FDB7: B1 06		lda ($06),y
0000FDB9: 20 82 FD      jsr $FD82       ;(*) 3000=A
0000FDBC: CA		dex
0000FDBD: D0 FA		bne $0000FDB9
0000FDBF: C6 09		dec $09
0000FDC1: 10 F6		bpl $0000FDB9
0000FDC3: 60		rts

[CALL]

0000FDC4: A9 00         lda #$00
0000FDC6: F0 02         beq $0000FDCA   ;continues...

[BIOS FUNCTION (CALL)]

0000FDC8: A9 40         lda #$40
0000FDCA: 05 05		ora $05
0000FDCC: 48		pha
0000FDCD: A5 04		lda $04
0000FDCF: 20 D3 FD      jsr $FDD3       ;(*) 3001=A
0000FDD2: 68            pla             ;continues...

[BIOS FUNCTION (CALL)]                  ;[*] write 3001

0000FDD3: 8D 01 30      sta $3001       ;VDP port #1w
0000FDD6: 60		rts

[code?]

0000FDD7: 85 04		sta $04
0000FDD9: 06 04		asl $04
0000FDDB: 26 05		rol $05
0000FDDD: 06 04		asl $04
0000FDDF: 26 05		rol $05
0000FDE1: 06 04		asl $04
0000FDE3: 26 05		rol $05
0000FDE5: 06 05		asl $05
0000FDE7: 06 05		asl $05
0000FDE9: 06 05		asl $05
0000FDEB: 60		rts

[CALL]

0000FDEC: 46 05		lsr $05
0000FDEE: 46 05		lsr $05
0000FDF0: 46 05		lsr $05
0000FDF2: 46 05		lsr $05
0000FDF4: 66 04		ror $04
0000FDF6: 46 05		lsr $05
0000FDF8: 66 04		ror $04
0000FDFA: 46 05		lsr $05
0000FDFC: 66 04		ror $04
0000FDFE: 60		rts

[CALL]

0000FDFF: 20 EC FD      jsr $FDEC       ;(*)
0000FE02: A5 05		lda $05
0000FE04: 09 10		ora #$10
0000FE06: 85 05		sta $05
0000FE08: 60		rts

[BIOS FUNCION (via jump)]

0000FE09: 20 FF FD      jsr $FDFF       ;(*)
0000FE0C: 20 C4 FD      jsr $FDC4       ;(*) continues...

[CALL]

0000FE0F: AD 00 20      lda $2000       ;VDP port #0r
0000FE12: 60		rts

[CODE?]

0000FE13: 48		pha
0000FE14: 20 FF FD	jsr $FDFF
0000FE17: 20 C8 FD	jsr $FDC8
0000FE1A: 68		pla
0000FE1B: 20 82 FD      jsr $FD82       ;(*) 3000=A
0000FE1E: 60		rts

[BIOS FUNCTION (CALL)]                  ;[*] IRQ OFF, 3001=A, 3001=X^0x80 

0000FE1F: 08            php             ;save IRQ status
0000FE20: 78            sei             ;IRQ OFF
0000FE21: 20 D3 FD      jsr $FDD3       ;(*) 3001=A
0000FE24: 8A            txa             ;get X, A is lost
0000FE25: 49 80         eor #$80        ;0=VDP register 1=VDP ram
0000FE27: 20 D3 FD      jsr $FDD3       ;(*) 3001=A
0000FE2A: 28            plp             ;retrieve IRQ status
0000FE2B: 60            rts             ;returns A=X

[IRQ]

0000FE2C: 6C FE BF      jmp ($BFFE)

[CALL - clear zeropage]

0000FE2F: A2 00         ldx #$00
0000FE31: 8A		txa
0000FE32: 95 00		sta $00,x
0000FE34: E8		inx
0000FE35: D0 FB		bne $0000FE32
0000FE37: 60		rts

[BIOS FUNCTION (CALL)]

0000FE38: A2 C6         ldx #$C6
0000FE3A: A9 00		lda #$00
0000FE3C: 20 1F FE      jsr $FE1F       ;(*) IRQ OFF, 3001=A, 3001=X^0x80
;
0000FE3F: A2 00         ldx #$00        ;f800-f8ff -> VDP ram
0000FE41: BD 00 F8	lda $F800,x
0000FE44: 20 82 FD      jsr $FD82       ;(*) 3000=A
0000FE47: E8		inx
0000FE48: D0 F7		bne $0000FE41
;
0000FE4A: BD 00 F9      lda $F900,x     ;f900-f9ff -> VDP ram
0000FE4D: 20 82 FD      jsr $FD82       ;(*) 3000=A
0000FE50: E8		inx
0000FE51: D0 F7		bne $0000FE4A
0000FE53: 60		rts

[BIOS FUNCTION (CALL)]                  ;[*] write 1002,1003 return 1002

0000FE54: 20 67 FE      jsr $FE67       ;write PIA 1002,1003
0000FE57: A2 03		ldx #$03
0000FE59: BD 63 FE	lda $FE63,x
0000FE5C: 20 77 FE      jsr $FE77       ;write PIA 1002, return 1002
0000FE5F: CA		dex
0000FE60: 10 F7		bpl $0000FE59
0000FE62: 60		rts

[DATA]

0000FE63: FF            .db $FF         ;3) 1 111 1111 PSG noise volume
0000FE64: DF            .db $DF         ;2) 1 101 1111 PSG channel 0 volume
0000FE65: BF            .db $BF         ;1) 1 011 1111 PSG channel 0 volume
0000FE66: 9F            .db $9F         ;0) 1 001 1111 PSG channel 0 volume

[CALL]                                  ;[*] write 1002,1003

0000FE67: A9 22         lda #$22        ;0010 0010 DDRB
0000FE69: 8D 03 10      sta $1003
0000FE6C: A9 FF         lda #$FF        ;ALL OUTPUT LINE (PSG out)
0000FE6E: 8D 02 10      sta $1002
0000FE71: A9 26         lda #$26        ;0010 0110 IORB
0000FE73: 8D 03 10      sta $1003
0000FE76: 60		rts

[BIOS FUNCTION (CALL)]                  ;[*] write 1002, return 1002

0000FE77: 8D 02 10      sta $1002       ;IORB
0000FE7A: AD 03 10      lda $1003       ;handshake
0000FE7D: 10 FB         bpl $0000FE7A
0000FE7F: AD 02 10      lda $1002       ;always(?) discarded
0000FE82: 60		rts

[BIOS FUNCTION]

0000FE83: A5 15		lda $15
0000FE85: F0 13		beq $0000FE9A
0000FE87: C6 0F		dec $0F
0000FE89: 10 11		bpl $0000FE9C
0000FE8B: E6 0D		inc $0D
0000FE8D: A5 0D		lda $0D
0000FE8F: 38		sec
0000FE90: ED ED BF	sbc $BFED
0000FE93: D0 02		bne $0000FE97
0000FE95: 85 0D		sta $0D
0000FE97: AD E7 BF	lda $BFE7
0000FE9A: 85 0F		sta $0F
0000FE9C: AD EE BF	lda $BFEE
0000FE9F: AE EF BF	ldx $BFEF
0000FEA2: 20 1F FE      jsr $FE1F       ;(*) IRQ OFF, 3001=A, 3001=X^0x80
0000FEA5: A5 0D		lda $0D
0000FEA7: 18		clc
0000FEA8: 69 01		adc #$01
0000FEAA: 20 C5 FE      jsr $FEC5       ;(*)
0000FEAD: 48		pha
0000FEAE: 4A		lsr a
0000FEAF: 4A		lsr a
0000FEB0: 4A		lsr a
0000FEB1: 4A		lsr a
0000FEB2: 20 B8 FE      jsr $FEB8       ;(*)
0000FEB5: 68		pla
0000FEB6: 29 0F		and #$0F
0000FEB8: C9 0A		cmp #$0A
0000FEBA: 90 02		bcc $0000FEBE
0000FEBC: 69 06		adc #$06
0000FEBE: 6D EC BF	adc $BFEC
0000FEC1: 20 82 FD      jsr $FD82       ;(*) 3000=A
0000FEC4: 60		rts

[BIOS FUNCTION (CALL)]

0000FEC5: A8		tay
0000FEC6: A2 00		ldx #$00
0000FEC8: A9 0A		lda #$0A
0000FECA: 85 0E		sta $0E
0000FECC: A9 00		lda #$00
0000FECE: C4 0E		cpy $0E
0000FED0: 90 0C		bcc $0000FEDE
0000FED2: E8		inx
0000FED3: E8		inx
0000FED4: E8		inx
0000FED5: E8		inx
0000FED6: E8		inx
0000FED7: E8		inx
0000FED8: A9 09		lda #$09
0000FEDA: 65 0E		adc $0E
0000FEDC: 90 EC		bcc $0000FECA
0000FEDE: 86 0E		stx $0E
0000FEE0: 98		tya
0000FEE1: 65 0E		adc $0E
0000FEE3: 60		rts

[CALL]

0000FEE4: 86 07		stx $07
0000FEE6: 85 06         sta $06         ;continues...

[CALL]

0000FEE8: A0 08		ldy #$08
0000FEEA: 20 BA FF      jsr $FFBA       ;(*)
0000FEED: A9 F8         lda #$F8        ;continues...

[CALL]

0000FEEF: 18		clc
0000FEF0: 65 06		adc $06
0000FEF2: 85 06		sta $06
0000FEF4: B0 02		bcs $0000FEF8
0000FEF6: C6 07		dec $07
0000FEF8: 60		rts

[BIOS FUNCTION]

0000FEF9: 20 E4 FE      jsr $FEE4       ;(*)
0000FEFC: 20 E8 FE      jsr $FEE8       ;(*)
0000FEFF: A9 20		lda #$20
0000FF01: 20 24 FF      jsr $FF24       ;(*)
0000FF04: 20 E8 FE      jsr $FEE8       ;(*)
0000FF07: 4C E8 FE      jmp $FEE8

[CALL]

0000FF0A: 86 07		stx $07
0000FF0C: 85 06         sta $06         ;continues...

[CALL]

0000FF0E: A0 F8		ldy #$F8
0000FF10: B1 06		lda ($06),y
0000FF12: 85 09		sta $09
0000FF14: A2 07		ldx #$07
0000FF16: 06 09		asl $09
0000FF18: 6A		ror a
0000FF19: CA		dex
0000FF1A: 10 FA		bpl $0000FF16
0000FF1C: 20 82 FD      jsr $FD82       ;(*) 3000=A
0000FF1F: C8		iny
0000FF20: D0 EE		bne $0000FF10
0000FF22: A9 08         lda #$08        ;continues...

[CALL]

0000FF24: 18		clc
0000FF25: 65 06		adc $06
0000FF27: 85 06		sta $06
0000FF29: 90 02		bcc $0000FF2D
0000FF2B: E6 07		inc $07
0000FF2D: 60		rts

[BIOS FUNCTION]

0000FF2E: 20 0A FF      jsr $FF0A       ;(*)
0000FF31: 20 0E FF      jsr $FF0E       ;(*)
0000FF34: A9 E0		lda #$E0
0000FF36: 20 EF FE      jsr $FEEF       ;(*)
0000FF39: 20 0E FF      jsr $FF0E       ;(*)
0000FF3C: 4C 0E FF	jmp $FF0E

[CARTRIDGE IRQ HANDLER]

0000FF3F: 48		pha
0000FF40: 8A		txa
0000FF41: 48		pha
0000FF42: 98		tya
0000FF43: 48		pha
0000FF44: AD 01 20      lda $2001       ;VDP port #1r (reset INT flag,as need)
0000FF47: 85 0C		sta $0C
0000FF49: 20 58 FF      jsr $FF58       ;(*)
0000FF4C: 20 00 FA      jsr $FA00       ;(*)
0000FF4F: 6C EA BF	jmp ($BFEA)

[BIOS FUNCTION - IRQ RETURN]

0000FF52: 68		pla
0000FF53: A8		tay
0000FF54: 68		pla
0000FF55: AA		tax
0000FF56: 68		pla
0000FF57: 40		rti

[BIOS FUNCTION (CALL)]

0000FF58: A9 20		lda #$20
0000FF5A: 25 03		and $03
0000FF5C: 0A		asl a
0000FF5D: 45 03		eor $03
0000FF5F: 0A		asl a
0000FF60: 0A		asl a
0000FF61: 26 02		rol $02
0000FF63: 26 03		rol $03
0000FF65: 60		rts

[RESET CODE]

0000FF66: 78            sei             ;disable IRQ
0000FF67: D8            cld             ;no BCD
;
0000FF68: A2 40         ldx #$40        ;Delay 300~ msec
0000FF6A: 88            dey
0000FF6B: D0 FD         bne $0000FF6A
0000FF6D: CA		dex
0000FF6E: D0 FA		bne $0000FF6A
;
0000FF70: AD 01 20      lda $2001       ;VDP port #1r (reset status)
0000FF73: 20 54 FE      jsr $FE54       ;(*) silence PSG (PIA outport B)
0000FF76: 20 4B F8      jsr $F84B       ;(*) VDP (game) setup
;
0000FF79: A2 05         ldx #$05        ;"software vectors" bffe..bffc
0000FF7B: CA		dex
0000FF7C: F0 20         beq $0000FF9E   ;stessi vettori,salta alla cartuccia 
0000FF7E: BD FB BF      lda $BFFB,x     ;vettori (software)
0000FF81: DD FF 01      cmp $01FF,x     ;vettori 200
0000FF84: F0 F5         beq $0000FF7B   ;loop
;
0000FF86: 20 2F FE      jsr $FE2F       ;(*) clear zeropage
0000FF89: A9 F4		lda #$F4
0000FF8B: 20 5C F8      jsr $F85C       ;(*) clear VDP ram
0000FF8E: 20 38 FE      jsr $FE38       ;(*) BIOS fonts in VDP ram
;
0000FF91: A2 03         ldx #$03        ;copy "software vectors" in $0200
0000FF93: BD FC BF      lda $BFFC,x
0000FF96: 9D 00 02	sta $0200,x
0000FF99: CA		dex
0000FF9A: 10 F7         bpl $0000FF93
;
0000FF9C: 86 02         stx $02         ;$0002=ff
0000FF9E: 6C FC BF      jmp ($BFFC)     ;TARGET nella cartuccia

[BIOS FUNCTION]

0000FFA1: BC 00 BF      ldy $BF00,x
0000FFA4: AD E6 BF	lda $BFE6
0000FFA7: 85 07		sta $07
0000FFA9: BD 01 BF	lda $BF01,x
0000FFAC: 85 06		sta $06
0000FFAE: BD 02 BF	lda $BF02,x
0000FFB1: 8D 01 30      sta $3001       ;VDP port #1w
0000FFB4: BD 03 BF	lda $BF03,x
0000FFB7: 20 D3 FD      jsr $FDD3       ;(*) 3001=A    continues...

[CALL]

0000FFBA: B1 06		lda ($06),y
0000FFBC: 20 82 FD      jsr $FD82       ;(*) 3000=A
0000FFBF: 88		dey
0000FFC0: D0 F8		bne $0000FFBA
0000FFC2: 60		rts

0000FFC3: 'HIHIGH SCORE2UP1UP GAME OVER '       ;capovolto e displaced 0x60

[BIOS FUNCTION]

0000FFE0: A9 EB         lda #$EB
0000FFE2: A2 FF		ldx #$FF
0000FFE4: 20 9E FD      jsr $FD9E       ;(*)
0000FFE7: C8		iny
0000FFE8: 4C A4 FD	jmp $FDA4

0000FFEB: misc data

0000FFFA: NMI
0000FFFC: RESET
0000FFFE: IRQ
Post Reply