Kapooka - homebrew logic game

Talk about programming of homebrew games only.
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 » Mon Dec 06, 2010 3:17 pm

Perhaps this thread should be renamed or split, but since we are so few participants it doesn't matter too much...

Anyway, I was thinking about the CHAR command, if it would be possible to make it dynamic. Apprently it is not easily possible:

10 A$="0000FFFF0000FFFF"
20 CHAR32,A$

This program redefines the space to some garbage and then empty space. It made me look closer at the CHAR command to find it accepts a text string WITHOUT quotes. I experimented a little more and came up with this cute thing:

10 CHAR32,JENSFOFWVONCZUGW

Try it for yourself.. it is perfectly valid code, at least in the speed-hack Basic release.

Again I am considering if we could use any part of the low CPU RAM, but it is a matter of how to make the transition from Basic work memory to VDP graphic memory, which actually is the same thing but Basic doesn't allow us to VPOKE directly to memory.

However it made me remember the previous hack where it seems possible to move the screen with POKE 219. Perhaps if we carefully move the screen to point to custom character area and PLOT data into that memory, we could obtain dynamic graphics? I need to consider this a bit more.

I got this far, but nothing useful is happening:

Code: Select all

10 POKE219,193
20 DATA62,124,248,240,248,124,62,0
30 FORI=1TO8
40 READB
50 PLOTI,1,B
60 NEXTI
70 POKE219,207
In theory, this program should relocate the screen matrix from $1000 to $0100, i.e. right where the space character is located. It would plot ASCII values of which most are non-printable to the screen, to make up for character data in the end. Once it is done, it would restore the screen matrix and ideally all our spaces would be replaced by the graphic symbol.

I tried to add PRINTPEEK(12289) before or after the POKEs, but no difference.
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 » Mon Dec 06, 2010 4:24 pm

Instead of finding my way in the dark, I loaded the Basic ROM into the VICE emulator and went to disassemble in the monitor. I am looking for $DB (decimal 219). It can be found at eight locations of which five consist of relevant code:

Code: Select all

.C:4243   A9 6D      LDA #$6D
.C:4245   A2 78      LDX #$78
.C:4247   20 53 FD   JSR $FD53
.C:424a   A9 D1      LDA #$D1
.C:424c   85 DB      STA $DB
.C:424e   A9 02      LDA #$02
.C:4250   85 DA      STA $DA
.C:4252   20 84 72   JSR $7284
.C:4255   4C CA 78   JMP $78CA
This routine seems to set up the registers to begin printing at $D102, i.e. second page of the screen matrix.

Code: Select all

.C:43ff   A5 DA      LDA $DA
.C:4401   18         CLC
.C:4402   69 20      ADC #$20
.C:4404   85 DA      STA $DA
.C:4406   C9 02      CMP #$02
.C:4408   D0 02      BNE $440C
.C:440a   E6 DB      INC $DB
.C:440c   60         RTS
This routine appears to move the cursor position down by a row.

Code: Select all

.C:440d   A9 00      LDA #$00
.C:440f   8D 4E 03   STA $034E
.C:4412   A5 DA      LDA $DA
.C:4414   C9 E2      CMP #$E2
.C:4416   D0 E7      BNE $43FF
.C:4418   A5 DB      LDA $DB
.C:441a   C9 D2      CMP #$D2
.C:441c   D0 E1      BNE $43FF
.C:441e   A2 D0      LDX #$D0
.C:4420   A9 00      LDA #$00
.C:4422   86 CE      STX $CE
.C:4424   85 CF      STA $CF
.C:4426   A6 CE      LDX $CE
.C:4428   A5 CF      LDA $CF
.C:442a   18         CLC
.C:442b   69 20      ADC #$20
.C:442d   D0 01      BNE $4430
.C:442f   E8         INX
.C:4430   20 D0 78   JSR $78D0
.C:4433   20 54 74   JSR $7454
.C:4436   A6 CE      LDX $CE
.C:4438   A5 CF      LDA $CF
.C:443a   20 1F FE   JSR $FE1F
.C:443d   20 62 74   JSR $7462
.C:4440   A5 CF      LDA $CF
.C:4442   18         CLC
.C:4443   69 20      ADC #$20
.C:4445   85 CF      STA $CF
.C:4447   D0 DD      BNE $4426
.C:4449   E6 CE      INC $CE
.C:444b   A5 CE      LDA $CE
.C:444d   C9 D3      CMP #$D3
.C:444f   D0 D5      BNE $4426
.C:4451   60         RTS
This routine links with the above one. $FE1F is a BIOS routine that MADrigal posted before:

Code: Select all

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

Code: Select all

.C:4c66   A9 D2      LDA #$D2
.C:4c68   85 DB      STA $DB
.C:4c6a   A9 E2      LDA #$E2
.C:4c6c   85 DA      STA $DA
.C:4c6e   20 86 FD   JSR $FD86
.C:4c71   4C 16 A9   JMP $A916
This routine relocates cursor to $D2E2.. that equals row 24, column 2 so the bottom row of the screen.

Code: Select all

.C:4e74   A5 D3      LDA $D3
.C:4e76   18         CLC
.C:4e77   6D 4E 03   ADC $034E
.C:4e7a   18         CLC
.C:4e7b   65 D2      ADC $D2
.C:4e7d   18         CLC
.C:4e7e   65 D4      ADC $D4
.C:4e80   18         CLC
.C:4e81   65 DA      ADC $DA
.C:4e83   A6 DB      LDX $DB
.C:4e85   20 1F FE   JSR $FE1F
.C:4e88   60         RTS
Another call to $FE1F which takes a couple of zeropage registers as input.

A more complete disassembly of Basic would be in order, but given how many places use hard-coded values, I wonder if address 219 really is useful after all in order to trick it to use a different memory area? Perhaps my time would be better spent trying to understand the VDP itself and go directly to machine code. Unfortunately it means I'd need to use my Diagnostic Cart w/ removable EPROM in order to transfer executables to the real machine.
Post Reply