COLOR_GREY1 = 2
COLOR_BLACK = 3
-;-------------------------------------------------------------------------------
; bios zp usage:
-;
-; 06/07 address of character set bitplane 1
-; 08/09 address of character set bitplane 2
-; 0a nmi $4800 echo
-; 0b irq counter
-; 0c nmi call cart nmi
-; 0e/0f/10/11 big endian irq counter
-; 15/16/17 ?/xpos/ypos
-;
-; e8 nmi reset to $ff
-;
-
ZP_NMI_4800 = $0a
-ZP_NMI_ENABLE = $0c
+ZP_IRQ_COUNT = $0b
+ZP_IRQ_CTRL = $0c
+
+ZP_IRQ_CNT1 = $0e
+ZP_IRQ_CNT2 = $0f
+ZP_IRQ_CNT3 = $10
+ZP_IRQ_CNT4 = $11
+ZP_NMI_FLAG = $e8
MEMORY {
# 0000-03ff is RAM
# FIXME: what zp range can we actually use?
- ZP: start = $0020, size = $e0;
+ # $0a-$11 is used by IRQ/NMI, $e8 is used by NMI
+ ZP: start = $0012, size = $e8 - $12;
CPUSTACK: start = $0100, size =$100;
RAM: start = $0200, size = $200 - __STACKSIZE__, define = yes;
/*
base clock cpu clock/32 ?
-0/1: 1. channel(right): 12 bit frequency: right frequency 0 nothing, 1 high; 3 23khz; 4 17,3; 10 6,9; 15 4.6; $60 720hz; $eff 18,0; $fff 16,9 hz)
+0/1: 1. channel(right): 12 bit frequency: right frequency 0 nothing, 1 high;
+ 3 23khz; 4 17,3; 10 6,9; 15 4.6; $60 720hz; $eff 18,0; $fff 16,9 hz)
(delay clock/32)
2/3: 2. channel(left): 12 bit frequency
4/5: 3. channel(both): 12 bit frequency
#define LCD_READ 0x5006 /* read from RAM (no auto inc?) */
#define LCD_DATA 0x5007 /* write to RAM */
+/* BIOS zeropage usage */
+
+/* locations 0x0a-0x0c, 0x0e-0x11 and 0xe8 are in use by the BIOS IRQ/NMI handlers */
+#define ZP_NMI_4800 0x0a /* content of I/O reg 4800 gets copied here each NMI */
+
+#define ZP_IRQ_COUNT 0x0b /* increments once per IRQ, used elsewhere in the
+ BIOS for synchronisation purposes */
+#define ZP_IRQ_CTRL 0x0c /* if 0 then cartridge irq stubs will not get called */
+
+/* each of the following 4 increments by 1 per IRQ - it is _not_ a 32bit
+ counter (see code at $ffa6 in BIOS)
+ these are not used elsewhere in the bios and can be (re)setted as needed by
+ the user.
+*/
+#define ZP_IRQ_CNT1 0x0e
+#define ZP_IRQ_CNT2 0x0f
+#define ZP_IRQ_CNT3 0x10
+#define ZP_IRQ_CNT4 0x11
+
+#define ZP_NMI_FLAG 0xe8 /* set to 0xff each NMI */
/* constants for the conio implementation */
#define COLOR_BLACK 0x03
# define CLK_TCK 60 /* POSIX */
# define CLOCKS_PER_SEC 60 /* ANSI */
#elif defined(__GAMATE__)
-# define CLK_TCK 60 /* POSIX */ /* FIXME */
-# define CLOCKS_PER_SEC 60 /* ANSI */ /* FIXME */
+# define CLK_TCK 135 /* POSIX */ /* FIXME */
+# define CLOCKS_PER_SEC 135 /* ANSI */ /* FIXME */
#elif defined(__GEOS__)
# define CLK_TCK 1 /* POSIX */
# define CLOCKS_PER_SEC 1 /* ANSI */
.export _clrscr
_clrscr:
ldy #$0
+ tya
rowloop:
sty LCD_X
- lda #0
sta LCD_Y
ldx #$0
; position in Y
putchar:
-
-; FIXME
-; ora RVS ; Set revers bit
-
-; sty temp_y
-; stx temp_x
-; sta temp_a
-
-; lda temp_a
-
sta ptr3
txa
bne @copylp2
@skip_plane2:
-
-
pla
tax
ldy CURS_X
sei
cld
+ ldx #0
+ stx ZP_IRQ_CTRL ; disable calling cartridge IRQ/NMI handler
+
; Setup stack and memory mapping
- ldx #$FF ; Stack top ($01FF)
+ ;ldx #$FF ; Stack top ($01FF)
+ dex
txs
; Clear the BSS data
; Call module constructors
jsr initlib
+ lda #1
+ sta ZP_IRQ_CTRL ; enable calling cartridge IRQ/NMI handler
cli ; allow IRQ only after constructors have run
; Pass an empty command line
;
; extzp.inc for the Gamate
;
-; Groepaz/Hitmen, 2015-11-19
+; Groepaz/Hitmen, 2015-11-27
;
; Assembler include file that imports the runtime zero page locations used
; by the Gamate runtime, ready for usage in asm code.
;
-; Groepaz/Hitmen, 2015-11-19
+; Groepaz/Hitmen, 2015-11-27
;
; zeropage locations for exclusive use by the library
;
; -> guess 16384 clock cycles = 135,28hz (might be audio signal 1/512?)
IRQStub:
- pha
- tya
- pha
+ ; A and Y are saved by the BIOS
+ ;pha
+ ;tya
+ ;pha
ldy #<(__INTERRUPTOR_COUNT__ * 2)
beq @L1
pla
tax
-@L1: pla
- tay
- pla
+@L1: ;pla
+ ;tay
+ ;pla
rts
;
.export NMIStub
+ .segment "INIT"
+
NMIStub:
- rts
\ No newline at end of file
+ ; A is saved by the BIOS
+ ;pha
+ ;txa
+ ;pha
+ ;tya
+ ;pha
+
+ ;pla
+ ;tay
+ ;pla
+ ;tax
+ ;pla
+ rts
-
+;
; original audiotest.s by PeT (mess@utanet.at)
+;
+; cl65 -t gamate -o audiotest.bin audiotest.s
+;
.include "gamate.inc"
.zeropage
-addr: .word 0
-psa: .word 0
-
-.word 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0 ; get out of sensitiv area
-
-readaddr: .word 0
-editbuffer1: .byte 0,0,0,0, 0,0,0,0 ;0,1,2,3,4,5,6,7
-writeaddr: .word 0
-editbuffer2: .byte 0,0,0,0, 0,0,0,0 ;8,9,$a,$b,$c,$d,$e,$f
-cursor: .byte 0
-controlslast: .byte 0
-controlsedge: .byte 0
-
-.data
-temp_x: .byte 0
-temp_y: .byte 0
-temp_a: .byte 0
-irq_count: .byte 0
-nmi_count: .byte 0
-psx: .byte 0
-psy: .byte 0
-xpos: .byte 0
-ypos: .byte 0
-
- .code
+addr: .word 0
+psa: .word 0
+readaddr: .word 0
+editbuffer1: .byte 0,0,0,0, 0,0,0,0
+writeaddr: .word 0
+editbuffer2: .byte 0,0,0,0, 0,0,0,0
+cursor: .byte 0
+controlslast: .byte 0
+controlsedge: .byte 0
+
+ .bss
+temp_x: .byte 0
+temp_y: .byte 0
+temp_a: .byte 0
+irq_count: .byte 0
+nmi_count: .byte 0
+psx: .byte 0
+psy: .byte 0
+xpos: .byte 0
+ypos: .byte 0
+
+ .rodata
chars: .incbin "cga2.chr"
hex2asc: .byte "0123456789abcdef"
+ .code
+
;-------------------------------------------------------------------------------
.export IRQStub, NMIStub
rts
.endproc
-.proc IRQStub
+.proc IRQStub
inc irq_count
rts
.endproc
.export Start
.proc Start
- lda #>AUDIO_BASE
- sta writeaddr+1
- sta readaddr+1
- lda #<AUDIO_BASE
- sta writeaddr
- sta readaddr
-
- lda #$10
- sta editbuffer1+6
- lda #$e
- sta editbuffer2+5
- lda #$ff
- sta editbuffer2+3
- lda #$ff
- sta editbuffer2+4
- lda #$0f
- sta editbuffer2
- lda #$0f
- sta editbuffer2+1
- lda #$0e
- sta editbuffer2+2
- lda #$38
- sta editbuffer1+7
-
- lda #0
- sta LCD_XPOS
- sta LCD_YPOS
- sta irq_count
- sta cursor
- lda #1
- sta nmi_count
+ sei
+ lda #0
+ sta ZP_IRQ_CTRL
+
+ lda #>AUDIO_BASE
+ sta writeaddr+1
+ sta readaddr+1
+ lda #<AUDIO_BASE
+ sta writeaddr
+ sta readaddr
+
+ lda #$10
+ sta editbuffer1+6
+ lda #$e
+ sta editbuffer2+5
+ lda #$ff
+ sta editbuffer2+3
+ lda #$ff
+ sta editbuffer2+4
+ lda #$0f
+ sta editbuffer2
+ lda #$0f
+ sta editbuffer2+1
+ lda #$0e
+ sta editbuffer2+2
+ lda #$38
+ sta editbuffer1+7
+
+ lda #0
+ sta LCD_XPOS
+ sta LCD_YPOS
+ sta irq_count
+ sta cursor
+ lda #1
+ sta nmi_count
cli
- lda #LCD_MODE_INC_Y
- sta LCD_MODE
+ lda #LCD_MODE_INC_Y
+ sta LCD_MODE
- jsr printy
+ jsr printy
- lda #1
- sta ZP_NMI_ENABLE
+ lda #1
+ sta ZP_IRQ_CTRL
-loop:
- lda irq_count
+loop:
+ lda irq_count
loop1:
- cmp irq_count
- beq loop1
- lda irq_count
- and #7
- bne loop1
-
- lda #LCD_MODE_INC_Y
- sta LCD_MODE
-
- ldx #3
- ldy #32
- lda irq_count
- jsr printhex
-
-
- lda cursor
- ldy #0
- cmp #20
- bcc firstline
+ cmp irq_count
+ beq loop1
+ lda irq_count
+ and #7
+ bne loop1
+
+ lda #LCD_MODE_INC_Y
+ sta LCD_MODE
+
+ ldx #3
+ ldy #32
+ lda irq_count
+ jsr printhex
+
+ lda cursor
+ ldy #0
+ cmp #20
+ bcc firstline
sec
- sbc #20
- ldy #24
+ sbc #20
+ ldy #24
firstline:
- sta LCD_X
- sty LCD_Y
- lda #' '
- jsr printsign
+ sta LCD_X
+ sty LCD_Y
+ lda #' '
+ jsr printsign
norclearcursor:
- jsr inputs
+ jsr inputs
- lda irq_count
- and #8
- bne nocursor
- lda cursor
- ldy #0
- cmp #20
- bcc firstline2
+ lda irq_count
+ and #8
+ bne nocursor
+ lda cursor
+ ldy #0
+ cmp #20
+ bcc firstline2
sec
- sbc #20
- ldy #24
+ sbc #20
+ ldy #24
firstline2:
- sta LCD_X
- sty LCD_Y
- lda #'x'
- jsr printsign
+ sta LCD_X
+ sty LCD_Y
+ lda #'x'
+ jsr printsign
nocursor:
- lda #LCD_MODE_INC_Y
- sta LCD_MODE
- jsr printy
- jmp loop
+ lda #LCD_MODE_INC_Y
+ sta LCD_MODE
+ jsr printy
+ jmp loop
.endproc
.proc printy
- ldy #0
+ ldy #0
loop1:
tya
pha
asl
tax
- lda readaddr,y
- ldy #8
- jsr printhex
+ lda readaddr,y
+ ldy #8
+ jsr printhex
pla
tay
iny
- cpy #10
- bne loop1
+ cpy #10
+ bne loop1
loop2:
tya
pha
tya
sec
- sbc #10
+ sbc #10
asl
tax
- lda readaddr,y
- ldy #16
- jsr printhex
+ lda readaddr,y
+ ldy #16
+ jsr printhex
pla
tay
iny
- cpy #20
- bne loop2
+ cpy #20
+ bne loop2
- ldx #0
- ldy #32
- lda nmi_count
- jsr printhex
+ ldx #0
+ ldy #32
+ lda nmi_count
+ jsr printhex
rts
.endproc
;-------------------------------------------------------------------------------
.proc inputs
- lda controlslast
- eor JOY_DATA
- and controlslast
- eor #$ff
- sta controlsedge
- and #JOY_DATA_UP
- bne notup
-
- lda cursor
+ lda controlslast
+ eor JOY_DATA
+ and controlslast
+ eor #$ff
+ sta controlsedge
+ and #JOY_DATA_UP
+ bne notup
+
+ lda cursor
lsr
tay
- bcs uplow
- lda readaddr,y
+ bcs uplow
+ lda readaddr,y
clc
- adc #$10
- sta readaddr,y
- jmp notup
-uplow:lda readaddr,y
+ adc #$10
+ sta readaddr,y
+ jmp notup
+uplow:
+ lda readaddr,y
clc
- adc #1
- sta readaddr,y
-notup:lda controlsedge
- and #JOY_DATA_DOWN
- bne notdown
- lda cursor
+ adc #1
+ sta readaddr,y
+notup:
+ lda controlsedge
+ and #JOY_DATA_DOWN
+ bne notdown
+ lda cursor
lsr
tay
- bcs downlow
- lda readaddr,y
+ bcs downlow
+ lda readaddr,y
sec
- sbc #$10
- sta readaddr,y
- jmp notdown
+ sbc #$10
+ sta readaddr,y
+ jmp notdown
downlow:
- lda readaddr,y
+ lda readaddr,y
sec
- sbc #1
- sta readaddr,y
-notdown:lda controlsedge
- and #JOY_DATA_LEFT
- bne notleft
- lda cursor
- beq notleft
- dec cursor
-notleft:lda controlsedge
- and #JOY_DATA_RIGHT
- bne notright
- lda cursor
- cmp #40
- beq notright
- inc cursor
-notright:lda controlsedge
- and #JOY_DATA_START
- bne notstart
- lda #0
- sta AUDIO_BASE
- sta AUDIO_BASE+1
- sta AUDIO_BASE+2
- sta AUDIO_BASE+3
- sta AUDIO_BASE+4
- sta AUDIO_BASE+5
- sta AUDIO_BASE+6
- sta AUDIO_BASE+8
- sta AUDIO_BASE+9
- sta AUDIO_BASE+10
- sta AUDIO_BASE+11
- sta AUDIO_BASE+12
- sta AUDIO_BASE+13
- sta AUDIO_BASE+7
-notstart:lda controlsedge
- and #JOY_DATA_SELECT
- bne notselect
- lda editbuffer1
- sta AUDIO_BASE
- lda editbuffer1+1
- sta AUDIO_BASE+1
- lda editbuffer1+2
- sta AUDIO_BASE+2
- lda editbuffer1+3
- sta AUDIO_BASE+3
- lda editbuffer1+4
- sta AUDIO_BASE+4
- lda editbuffer1+5
- sta AUDIO_BASE+5
- lda editbuffer1+6
- sta AUDIO_BASE+6
- lda editbuffer2
- sta AUDIO_BASE+8
- lda editbuffer2+1
- sta AUDIO_BASE+9
- lda editbuffer2+2
- sta AUDIO_BASE+10
- lda editbuffer2+3
- sta AUDIO_BASE+11
- lda editbuffer2+4
- sta AUDIO_BASE+12
- lda editbuffer2+5
- sta AUDIO_BASE+13
- lda editbuffer1+7
- sta AUDIO_BASE+7
-notselect:lda controlsedge
- and #JOY_DATA_FIRE_A
- bne notbuttona
- ldy #0
- ldy #0
-writea:lda editbuffer1,y
- sta (writeaddr),y
+ sbc #1
+ sta readaddr,y
+notdown:
+ lda controlsedge
+ and #JOY_DATA_LEFT
+ bne notleft
+ lda cursor
+ beq notleft
+ dec cursor
+notleft:
+ lda controlsedge
+ and #JOY_DATA_RIGHT
+ bne notright
+ lda cursor
+ cmp #40
+ beq notright
+ inc cursor
+notright:
+ lda controlsedge
+ and #JOY_DATA_START
+ bne notstart
+ lda #0
+ sta AUDIO_BASE
+ sta AUDIO_BASE+1
+ sta AUDIO_BASE+2
+ sta AUDIO_BASE+3
+ sta AUDIO_BASE+4
+ sta AUDIO_BASE+5
+ sta AUDIO_BASE+6
+ sta AUDIO_BASE+8
+ sta AUDIO_BASE+9
+ sta AUDIO_BASE+10
+ sta AUDIO_BASE+11
+ sta AUDIO_BASE+12
+ sta AUDIO_BASE+13
+ sta AUDIO_BASE+7
+notstart:
+ lda controlsedge
+ and #JOY_DATA_SELECT
+ bne notselect
+ lda editbuffer1
+ sta AUDIO_BASE
+ lda editbuffer1+1
+ sta AUDIO_BASE+1
+ lda editbuffer1+2
+ sta AUDIO_BASE+2
+ lda editbuffer1+3
+ sta AUDIO_BASE+3
+ lda editbuffer1+4
+ sta AUDIO_BASE+4
+ lda editbuffer1+5
+ sta AUDIO_BASE+5
+ lda editbuffer1+6
+ sta AUDIO_BASE+6
+ lda editbuffer2
+ sta AUDIO_BASE+8
+ lda editbuffer2+1
+ sta AUDIO_BASE+9
+ lda editbuffer2+2
+ sta AUDIO_BASE+10
+ lda editbuffer2+3
+ sta AUDIO_BASE+11
+ lda editbuffer2+4
+ sta AUDIO_BASE+12
+ lda editbuffer2+5
+ sta AUDIO_BASE+13
+ lda editbuffer1+7
+ sta AUDIO_BASE+7
+notselect:
+ lda controlsedge
+ and #JOY_DATA_FIRE_A
+ bne notbuttona
+ ldy #0
+ ldy #0
+writea:
+ lda editbuffer1,y
+ sta (writeaddr),y
iny
- cpy #8
- bne writea
-writeb:lda editbuffer2-8,y
- sta (writeaddr),y
+ cpy #8
+ bne writea
+writeb:
+ lda editbuffer2-8,y
+ sta (writeaddr),y
iny
- cpy #16
- bne writeb
-notbuttona:lda controlsedge
- and #JOY_DATA_FIRE_B
- bne notbuttonb
- ldy #0
-reada:lda (readaddr),y
- sta editbuffer1,y
+ cpy #16
+ bne writeb
+notbuttona:
+ lda controlsedge
+ and #JOY_DATA_FIRE_B
+ bne notbuttonb
+ ldy #0
+reada:
+ lda (readaddr),y
+ sta editbuffer1,y
iny
- cpy #8
- bne reada
-readb:lda (readaddr),y
- sta editbuffer2-8,y
+ cpy #8
+ bne reada
+
+readb: lda (readaddr),y
+ sta editbuffer2-8,y
iny
- cpy #16
+ cpy #16
bne readb
notbuttonb:
- lda JOY_DATA
- sta controlslast
+ lda JOY_DATA
+ sta controlslast
rts
.endproc
;-------------------------------------------------------------------------------
.proc printstring
- sta psa
- stx psa+1
- ldx #0
- stx psx
- sty psy
+ sta psa
+ stx psa+1
+ ldx #0
+ stx psx
+ sty psy
printstring2:
- ldy #0
- lda (psa),y
- beq printstring1
- ldx psx
- stx LCD_X
- ldy psy
- sty LCD_Y
- jsr printsign
- inc psx
- lda psa
+ ldy #0
+ lda (psa),y
+ beq printstring1
+ ldx psx
+ stx LCD_X
+ ldy psy
+ sty LCD_Y
+ jsr printsign
+ inc psx
+ lda psa
clc
- adc #1
- sta psa
- lda psa+1
- adc #0
- sta psa+1
- jmp printstring2
+ adc #1
+ sta psa
+ lda psa+1
+ adc #0
+ sta psa+1
+ jmp printstring2
printstring1:
rts
.endproc
.proc printstringy
- sta psa
- stx psa+1
+ sta psa
+ stx psa+1
printstring2:
- ldy #0
- lda (psa),y
- beq printstring1
- jsr printsign
- lda psa
+ ldy #0
+ lda (psa),y
+ beq printstring1
+ jsr printsign
+ lda psa
clc
- adc #1
- sta psa
- lda psa+1
- adc #0
- sta psa+1
- jmp printstring2
+ adc #1
+ sta psa
+ lda psa+1
+ adc #0
+ sta psa+1
+ jmp printstring2
printstring1:
rts
.endproc
lsr
lsr
lsr
- and #$0f
- stx temp_x
+ and #$0f
+ stx temp_x
tax
- lda hex2asc,x
- ldx temp_x
- stx LCD_X
- sty LCD_Y
- jsr printsign
+ lda hex2asc,x
+ ldx temp_x
+ stx LCD_X
+ sty LCD_Y
+ jsr printsign
pla
- and #$0f
+ and #$0f
inx
- stx temp_x
+ stx temp_x
tax
- lda hex2asc,x
- ldx temp_x
- stx LCD_X
- sty LCD_Y
- jmp printsign
+ lda hex2asc,x
+ ldx temp_x
+ stx LCD_X
+ sty LCD_Y
+ jmp printsign
.endproc
.proc printsign
- sty temp_y
- stx temp_x
- sta temp_a
- lda temp_a
- sta addr
- lda #0
- sta addr+1
- asl addr
- rol addr+1
- asl addr
- rol addr+1
- asl addr
- rol addr+1
- lda addr
+ sty temp_y
+ stx temp_x
+ sta temp_a
+ lda temp_a
+ sta addr
+ lda #0
+ sta addr+1
+ asl addr
+ rol addr+1
+ asl addr
+ rol addr+1
+ asl addr
+ rol addr+1
+ lda addr
clc
- adc #<chars
- sta addr
- lda addr+1
- adc #>chars
- sta addr+1
- ldx #8
- ldy #0
+ adc #<chars
+ sta addr
+ lda addr+1
+ adc #>chars
+ sta addr+1
+ ldx #8
+ ldy #0
printsign1:
- lda (addr),y
- sta LCD_DATA
+ lda (addr),y
+ sta LCD_DATA
iny
dex
- bne printsign1
- ldx temp_x
- ldy temp_y
+ bne printsign1
+ ldx temp_x
+ ldy temp_y
rts
.endproc
-
-
+;
; original lcdtest.s by PeT (mess@utanet.at)
+;
+; cl65 -t gamate -o lcdtest.bin lcdtest.s
+;
.include "gamate.inc"
.zeropage
-addr: .word 0
-psa: .word 0
-
- .data
-temp_x: .byte 0
-temp_y: .byte 0
-temp_a: .byte 0
-irq_count: .byte 0
-nmi_count: .byte 0
-psx: .byte 0
-psy: .byte 0
-count: .word 0
-counted: .word 0
-xpos: .byte 0
-ypos: .byte 0
-
-.code
-
-chars:
- .incbin "cga2.chr"
+addr: .word 0
+psa: .word 0
+
+ .bss
+temp_x: .byte 0
+temp_y: .byte 0
+temp_a: .byte 0
+irq_count: .byte 0
+nmi_count: .byte 0
+psx: .byte 0
+psy: .byte 0
+count: .word 0
+counted: .word 0
+xpos: .byte 0
+ypos: .byte 0
+
+ .rodata
+
+chars: .incbin "cga2.chr"
hex2asc: .byte "0123456789abcdef"
format: .byte "IrqNmiCountXposYpos", 0
xdesc: .byte "0123456789abcdefghijklmnopqrstuv", 0
ydesc: .byte "0123456789ABCDEFGHIJKLMNOPQRSTUV", 0
+ .code
+
;-------------------------------------------------------------------------------
.export IRQStub, NMIStub
.export Start
.proc Start
+ sei
+ lda #0
+ sta ZP_IRQ_CTRL
lda #0
- sta LCD_XPOS
- sta LCD_YPOS
+ sta LCD_XPOS
+ sta LCD_YPOS
cli
- lda #LCD_MODE_INC_Y
- sta LCD_MODE
+ lda #LCD_MODE_INC_Y
+ sta LCD_MODE
- lda #0
- sta LCD_X
- lda #<xdesc
- ldx #>xdesc
- ldy #0
- jsr printstring
-
- lda #LCD_XPOS_PLANE2
- sta LCD_X
- lda #<xdesc
- ldx #>xdesc
- ldy #128
- jsr printstring
+ lda #0
+ sta LCD_X
+ lda #<xdesc
+ ldx #>xdesc
+ ldy #0
+ jsr printstring
- lda #0
- sta LCD_X
- lda #<ydesc
- ldx #>ydesc
- ldy #0
- sty LCD_Y
- jsr printstringy
-
-; lda #$90;(LCD_XPOS_PLANE2|(128/8))
- lda #(LCD_XPOS_PLANE2|(128/8))
- sta LCD_X
- lda #<ydesc
- ldx #>ydesc
- ldy #0
- sty LCD_Y
- jsr printstringy
-
- lda #<format
- ldx #>format
- ldy #8
- jsr printstring
+ lda #LCD_XPOS_PLANE2
+ sta LCD_X
+ lda #<xdesc
+ ldx #>xdesc
+ ldy #128
+ jsr printstring
- lda #0
- sta LCD_MODE
- lda #24/8
- sta LCD_X
- lda #24
- sta LCD_Y
- lda #'X'
- jsr printsign
- lda #$80
- sta LCD_MODE
- lda #32/8
- sta LCD_X
- lda #32
- sta LCD_Y
- lda #'Y'
- jsr printsign
- lda #$c0
- sta LCD_MODE
- lda #40/8
- sta LCD_X
- lda #40
- sta LCD_Y
- lda #'Z'
- jsr printsign
+ lda #0
+ sta LCD_X
+ lda #<ydesc
+ ldx #>ydesc
+ ldy #0
+ sty LCD_Y
+ jsr printstringy
- lda #0
- sta LCD_MODE
- lda #LCD_XPOS_PLANE2|(48/8)
- sta LCD_X
- lda #48
- sta LCD_Y
- lda #'x'
- jsr printsign
- lda #$80
- sta LCD_MODE
- lda #(LCD_XPOS_PLANE2|(56/8))
- sta LCD_X
- lda #56
- sta LCD_Y
- lda #'y'
- jsr printsign
- lda #$c0
- sta LCD_MODE
- lda #(LCD_XPOS_PLANE2|(64/8))
- sta LCD_X
- lda #64
- sta LCD_Y
- lda #'z'
- jsr printsign
-
- lda #LCD_MODE_INC_Y|1
- sta LCD_MODE
- lda #16/8
- sta LCD_X
- lda #72
- sta LCD_Y
- lda #'V'
- jsr printsign
- lda #LCD_MODE_INC_Y|2
- sta LCD_MODE
- lda #24/8
- sta LCD_X
- lda #72
- sta LCD_Y
- lda #'V'
- jsr printsign
- lda #LCD_MODE_INC_Y|4
- sta LCD_MODE
- lda #32/8
- sta LCD_X
- lda #72
- sta LCD_Y
- lda #'V'
- jsr printsign
- lda #LCD_MODE_INC_Y|8
- sta LCD_MODE
- lda #40/8
- sta LCD_X
- lda #72
- sta LCD_Y
- lda #'V'
- jsr printsign
-
-
- lda #1
- sta ZP_NMI_ENABLE
-
-loop: lda count
+ lda #(LCD_XPOS_PLANE2|(128/8)) ; ???
+ sta LCD_X
+ lda #<ydesc
+ ldx #>ydesc
+ ldy #0
+ sty LCD_Y
+ jsr printstringy
+
+ lda #<format
+ ldx #>format
+ ldy #8
+ jsr printstring
+
+ lda #0
+ sta LCD_MODE
+ lda #24/8
+ sta LCD_X
+ lda #24
+ sta LCD_Y
+ lda #'X'
+ jsr printsign
+
+ lda #$80
+ sta LCD_MODE
+ lda #32/8
+ sta LCD_X
+ lda #32
+ sta LCD_Y
+ lda #'Y'
+ jsr printsign
+
+ lda #$c0
+ sta LCD_MODE
+ lda #40/8
+ sta LCD_X
+ lda #40
+ sta LCD_Y
+ lda #'Z'
+ jsr printsign
+
+ lda #0
+ sta LCD_MODE
+ lda #LCD_XPOS_PLANE2|(48/8)
+ sta LCD_X
+ lda #48
+ sta LCD_Y
+ lda #'x'
+ jsr printsign
+
+ lda #$80
+ sta LCD_MODE
+ lda #(LCD_XPOS_PLANE2|(56/8))
+ sta LCD_X
+ lda #56
+ sta LCD_Y
+ lda #'y'
+ jsr printsign
+
+ lda #$c0
+ sta LCD_MODE
+ lda #(LCD_XPOS_PLANE2|(64/8))
+ sta LCD_X
+ lda #64
+ sta LCD_Y
+ lda #'z'
+ jsr printsign
+
+ lda #LCD_MODE_INC_Y|1
+ sta LCD_MODE
+ lda #16/8
+ sta LCD_X
+ lda #72
+ sta LCD_Y
+ lda #'V'
+ jsr printsign
+
+ lda #LCD_MODE_INC_Y|2
+ sta LCD_MODE
+ lda #24/8
+ sta LCD_X
+ lda #72
+ sta LCD_Y
+ lda #'V'
+ jsr printsign
+
+ lda #LCD_MODE_INC_Y|4
+ sta LCD_MODE
+ lda #32/8
+ sta LCD_X
+ lda #72
+ sta LCD_Y
+ lda #'V'
+ jsr printsign
+
+ lda #LCD_MODE_INC_Y|8
+ sta LCD_MODE
+ lda #40/8
+ sta LCD_X
+ lda #72
+ sta LCD_Y
+ lda #'V'
+ jsr printsign
+
+ lda #1
+ sta ZP_IRQ_CTRL
+
+loop:
+ lda count
clc
- adc #1
- sta count
- lda count+1
- adc #1
- sta count+1
- lda irq_count
- cmp irq_count
- beq loop
+ adc #1
+ sta count
+ lda count+1
+ adc #0
+ sta count+1
- jsr inputs
- lda #LCD_MODE_INC_Y
- sta LCD_MODE
- jsr printy
+ lda irq_count
+ cmp irq_count
+ beq loop
+ jsr inputs
+ lda #LCD_MODE_INC_Y
+ sta LCD_MODE
+ jsr printy
- jmp loop
+ jmp loop
.endproc
;-------------------------------------------------------------------------------
.proc printy
- ldx #0
- ldy #16
- lda irq_count
- jsr printhex
-
- ldx #3
- ldy #16
- lda nmi_count
- jsr printhex
-
- ldx #6
- ldy #16
- lda counted+1
- jsr printhex
- ldx #8
- ldy #16
- lda counted
- jsr printhex
-
- ldx #11
- ldy #16
- lda xpos
- jsr printhex
- ldx #14
- ldy #16
- lda ypos
- jsr printhex
+ ldx #0
+ ldy #16
+ lda irq_count
+ jsr printhex
+
+ ldx #3
+ ldy #16
+ lda nmi_count
+ jsr printhex
+
+ ldx #6
+ ldy #16
+ lda counted+1
+ jsr printhex
+ ldx #8
+ ldy #16
+ lda counted
+ jsr printhex
+
+ ldx #11
+ ldy #16
+ lda xpos
+ jsr printhex
+ ldx #14
+ ldy #16
+ lda ypos
+ jsr printhex
rts
.endproc
.proc inputs
- lda JOY_DATA
- and #JOY_DATA_UP
- bne notup
- dec ypos
- lda ypos
- sta LCD_YPOS
-notup:lda JOY_DATA
- and #JOY_DATA_DOWN
- bne notdown
- inc ypos
- lda ypos
- sta LCD_YPOS
-notdown:lda JOY_DATA
- and #JOY_DATA_LEFT
- bne notleft
- dec xpos
- lda xpos
- sta LCD_XPOS
-notleft:lda JOY_DATA
- and #JOY_DATA_RIGHT
- bne notright
- inc xpos
- lda xpos
- sta LCD_XPOS
-notright:lda JOY_DATA
- and #JOY_DATA_START
- bne notstart
-notstart:lda JOY_DATA
- and #JOY_DATA_SELECT
- bne notselect
-notselect:lda JOY_DATA
- and #JOY_DATA_FIRE_A
- bne notbuttona
-notbuttona:lda JOY_DATA
- and #JOY_DATA_FIRE_B
- bne notbuttonb
-notbuttonb:rts
+ lda JOY_DATA
+ and #JOY_DATA_UP
+ bne notup
+ dec ypos
+ lda ypos
+ sta LCD_YPOS
+notup:
+ lda JOY_DATA
+ and #JOY_DATA_DOWN
+ bne notdown
+ inc ypos
+ lda ypos
+ sta LCD_YPOS
+notdown:
+ lda JOY_DATA
+ and #JOY_DATA_LEFT
+ bne notleft
+ dec xpos
+ lda xpos
+ sta LCD_XPOS
+notleft:
+ lda JOY_DATA
+ and #JOY_DATA_RIGHT
+ bne notright
+ inc xpos
+ lda xpos
+ sta LCD_XPOS
+notright:
+ lda JOY_DATA
+ and #JOY_DATA_START
+ bne notstart
+notstart:
+ lda JOY_DATA
+ and #JOY_DATA_SELECT
+ bne notselect
+notselect:
+ lda JOY_DATA
+ and #JOY_DATA_FIRE_A
+ bne notbuttona
+notbuttona:
+ lda JOY_DATA
+ and #JOY_DATA_FIRE_B
+ bne notbuttonb
+notbuttonb:
+ rts
.endproc
;-------------------------------------------------------------------------------
.proc printstring
- sta psa
- stx psa+1
- ldx #0
- stx psx
- sty psy
+ sta psa
+ stx psa+1
+ ldx #0
+ stx psx
+ sty psy
printstring2:
- ldy #0
- lda (psa),y
- beq printstring1
- ldx psx
- stx LCD_X
- ldy psy
- sty LCD_Y
- jsr printsign
- inc psx
- lda psa
+ ldy #0
+ lda (psa),y
+ beq printstring1
+ ldx psx
+ stx LCD_X
+ ldy psy
+ sty LCD_Y
+ jsr printsign
+ inc psx
+ lda psa
clc
- adc #1
- sta psa
- lda psa+1
- adc #0
- sta psa+1
- jmp printstring2
+ adc #1
+ sta psa
+ lda psa+1
+ adc #0
+ sta psa+1
+ jmp printstring2
printstring1:
rts
.endproc
.proc printstringy
- sta psa
- stx psa+1
+ sta psa
+ stx psa+1
printstring2:
- ldy #0
- lda (psa),y
- beq printstring1
- jsr printsign
- lda psa
+ ldy #0
+ lda (psa),y
+ beq printstring1
+ jsr printsign
+ lda psa
clc
- adc #1
- sta psa
- lda psa+1
- adc #0
- sta psa+1
- jmp printstring2
+ adc #1
+ sta psa
+ lda psa+1
+ adc #0
+ sta psa+1
+ jmp printstring2
printstring1:
rts
.endproc
lsr
lsr
lsr
- and #$0f
- stx temp_x
+ and #$0f
+ stx temp_x
tax
- lda hex2asc,x
- ldx temp_x
- stx LCD_X
- sty LCD_Y
- jsr printsign
+ lda hex2asc,x
+ ldx temp_x
+ stx LCD_X
+ sty LCD_Y
+ jsr printsign
pla
- and #$0f
+ and #$0f
inx
- stx temp_x
+ stx temp_x
tax
- lda hex2asc,x
- ldx temp_x
- stx LCD_X
- sty LCD_Y
- jmp printsign
+ lda hex2asc,x
+ ldx temp_x
+ stx LCD_X
+ sty LCD_Y
+ jmp printsign
.endproc
.proc printsign