more cleanup

This commit is contained in:
mrdudz
2015-11-29 20:04:10 +01:00
parent c636675521
commit b39a8b7a61
13 changed files with 669 additions and 607 deletions

View File

@@ -51,20 +51,14 @@ COLOR_GREY2 = 1
COLOR_GREY1 = 2 COLOR_GREY1 = 2
COLOR_BLACK = 3 COLOR_BLACK = 3
;-------------------------------------------------------------------------------
; bios zp usage: ; 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_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

View File

@@ -8,7 +8,8 @@ SYMBOLS {
MEMORY { MEMORY {
# 0000-03ff is RAM # 0000-03ff is RAM
# FIXME: what zp range can we actually use? # 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; CPUSTACK: start = $0100, size =$100;
RAM: start = $0200, size = $200 - __STACKSIZE__, define = yes; RAM: start = $0200, size = $200 - __STACKSIZE__, define = yes;

View File

@@ -41,7 +41,8 @@
/* /*
base clock cpu clock/32 ? 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) (delay clock/32)
2/3: 2. channel(left): 12 bit frequency 2/3: 2. channel(left): 12 bit frequency
4/5: 3. channel(both): 12 bit frequency 4/5: 3. channel(both): 12 bit frequency
@@ -132,6 +133,26 @@
#define LCD_READ 0x5006 /* read from RAM (no auto inc?) */ #define LCD_READ 0x5006 /* read from RAM (no auto inc?) */
#define LCD_DATA 0x5007 /* write to RAM */ #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 */ /* constants for the conio implementation */
#define COLOR_BLACK 0x03 #define COLOR_BLACK 0x03

View File

@@ -103,8 +103,8 @@ unsigned _clocks_per_sec (void);
# define CLK_TCK 60 /* POSIX */ # define CLK_TCK 60 /* POSIX */
# define CLOCKS_PER_SEC 60 /* ANSI */ # define CLOCKS_PER_SEC 60 /* ANSI */
#elif defined(__GAMATE__) #elif defined(__GAMATE__)
# define CLK_TCK 60 /* POSIX */ /* FIXME */ # define CLK_TCK 135 /* POSIX */ /* FIXME */
# define CLOCKS_PER_SEC 60 /* ANSI */ /* FIXME */ # define CLOCKS_PER_SEC 135 /* ANSI */ /* FIXME */
#elif defined(__GEOS__) #elif defined(__GEOS__)
# define CLK_TCK 1 /* POSIX */ # define CLK_TCK 1 /* POSIX */
# define CLOCKS_PER_SEC 1 /* ANSI */ # define CLOCKS_PER_SEC 1 /* ANSI */

View File

@@ -6,10 +6,10 @@
.export _clrscr .export _clrscr
_clrscr: _clrscr:
ldy #$0 ldy #$0
tya
rowloop: rowloop:
sty LCD_X sty LCD_X
lda #0
sta LCD_Y sta LCD_Y
ldx #$0 ldx #$0

View File

@@ -65,16 +65,6 @@ plot: ldy CURS_X
; position in Y ; position in Y
putchar: putchar:
; FIXME
; ora RVS ; Set revers bit
; sty temp_y
; stx temp_x
; sta temp_a
; lda temp_a
sta ptr3 sta ptr3
txa txa
@@ -139,8 +129,6 @@ putchar:
bne @copylp2 bne @copylp2
@skip_plane2: @skip_plane2:
pla pla
tax tax
ldy CURS_X ldy CURS_X

View File

@@ -17,8 +17,12 @@ Start:
sei sei
cld cld
ldx #0
stx ZP_IRQ_CTRL ; disable calling cartridge IRQ/NMI handler
; Setup stack and memory mapping ; Setup stack and memory mapping
ldx #$FF ; Stack top ($01FF) ;ldx #$FF ; Stack top ($01FF)
dex
txs txs
; Clear the BSS data ; Clear the BSS data
@@ -36,6 +40,8 @@ Start:
; Call module constructors ; Call module constructors
jsr initlib jsr initlib
lda #1
sta ZP_IRQ_CTRL ; enable calling cartridge IRQ/NMI handler
cli ; allow IRQ only after constructors have run cli ; allow IRQ only after constructors have run
; Pass an empty command line ; Pass an empty command line

View File

@@ -1,7 +1,7 @@
; ;
; extzp.inc for the Gamate ; 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 ; Assembler include file that imports the runtime zero page locations used
; by the Gamate runtime, ready for usage in asm code. ; by the Gamate runtime, ready for usage in asm code.

View File

@@ -1,5 +1,5 @@
; ;
; Groepaz/Hitmen, 2015-11-19 ; Groepaz/Hitmen, 2015-11-27
; ;
; zeropage locations for exclusive use by the library ; zeropage locations for exclusive use by the library
; ;

View File

@@ -30,9 +30,10 @@ doneirq:
; -> guess 16384 clock cycles = 135,28hz (might be audio signal 1/512?) ; -> guess 16384 clock cycles = 135,28hz (might be audio signal 1/512?)
IRQStub: IRQStub:
pha ; A and Y are saved by the BIOS
tya ;pha
pha ;tya
;pha
ldy #<(__INTERRUPTOR_COUNT__ * 2) ldy #<(__INTERRUPTOR_COUNT__ * 2)
beq @L1 beq @L1
@@ -45,7 +46,7 @@ IRQStub:
pla pla
tax tax
@L1: pla @L1: ;pla
tay ;tay
pla ;pla
rts rts

View File

@@ -3,5 +3,19 @@
; ;
.export NMIStub .export NMIStub
.segment "INIT"
NMIStub: NMIStub:
; A is saved by the BIOS
;pha
;txa
;pha
;tya
;pha
;pla
;tay
;pla
;tax
;pla
rts rts

View File

@@ -1,23 +1,23 @@
;
; original audiotest.s by PeT (mess@utanet.at) ; original audiotest.s by PeT (mess@utanet.at)
;
; cl65 -t gamate -o audiotest.bin audiotest.s
;
.include "gamate.inc" .include "gamate.inc"
.zeropage .zeropage
addr: .word 0 addr: .word 0
psa: .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 readaddr: .word 0
editbuffer1: .byte 0,0,0,0, 0,0,0,0 ;0,1,2,3,4,5,6,7 editbuffer1: .byte 0,0,0,0, 0,0,0,0
writeaddr: .word 0 writeaddr: .word 0
editbuffer2: .byte 0,0,0,0, 0,0,0,0 ;8,9,$a,$b,$c,$d,$e,$f editbuffer2: .byte 0,0,0,0, 0,0,0,0
cursor: .byte 0 cursor: .byte 0
controlslast: .byte 0 controlslast: .byte 0
controlsedge: .byte 0 controlsedge: .byte 0
.data .bss
temp_x: .byte 0 temp_x: .byte 0
temp_y: .byte 0 temp_y: .byte 0
temp_a: .byte 0 temp_a: .byte 0
@@ -28,11 +28,13 @@ psy: .byte 0
xpos: .byte 0 xpos: .byte 0
ypos: .byte 0 ypos: .byte 0
.code .rodata
chars: .incbin "cga2.chr" chars: .incbin "cga2.chr"
hex2asc: .byte "0123456789abcdef" hex2asc: .byte "0123456789abcdef"
.code
;------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------
.export IRQStub, NMIStub .export IRQStub, NMIStub
@@ -50,6 +52,10 @@ hex2asc: .byte "0123456789abcdef"
.export Start .export Start
.proc Start .proc Start
sei
lda #0
sta ZP_IRQ_CTRL
lda #>AUDIO_BASE lda #>AUDIO_BASE
sta writeaddr+1 sta writeaddr+1
sta readaddr+1 sta readaddr+1
@@ -88,7 +94,7 @@ hex2asc: .byte "0123456789abcdef"
jsr printy jsr printy
lda #1 lda #1
sta ZP_NMI_ENABLE sta ZP_IRQ_CTRL
loop: loop:
lda irq_count lda irq_count
@@ -107,7 +113,6 @@ loop1:
lda irq_count lda irq_count
jsr printhex jsr printhex
lda cursor lda cursor
ldy #0 ldy #0
cmp #20 cmp #20
@@ -209,11 +214,13 @@ loop2:
adc #$10 adc #$10
sta readaddr,y sta readaddr,y
jmp notup jmp notup
uplow:lda readaddr,y uplow:
lda readaddr,y
clc clc
adc #1 adc #1
sta readaddr,y sta readaddr,y
notup:lda controlsedge notup:
lda controlsedge
and #JOY_DATA_DOWN and #JOY_DATA_DOWN
bne notdown bne notdown
lda cursor lda cursor
@@ -230,20 +237,23 @@ downlow:
sec sec
sbc #1 sbc #1
sta readaddr,y sta readaddr,y
notdown:lda controlsedge notdown:
lda controlsedge
and #JOY_DATA_LEFT and #JOY_DATA_LEFT
bne notleft bne notleft
lda cursor lda cursor
beq notleft beq notleft
dec cursor dec cursor
notleft:lda controlsedge notleft:
lda controlsedge
and #JOY_DATA_RIGHT and #JOY_DATA_RIGHT
bne notright bne notright
lda cursor lda cursor
cmp #40 cmp #40
beq notright beq notright
inc cursor inc cursor
notright:lda controlsedge notright:
lda controlsedge
and #JOY_DATA_START and #JOY_DATA_START
bne notstart bne notstart
lda #0 lda #0
@@ -261,7 +271,8 @@ notright:lda controlsedge
sta AUDIO_BASE+12 sta AUDIO_BASE+12
sta AUDIO_BASE+13 sta AUDIO_BASE+13
sta AUDIO_BASE+7 sta AUDIO_BASE+7
notstart:lda controlsedge notstart:
lda controlsedge
and #JOY_DATA_SELECT and #JOY_DATA_SELECT
bne notselect bne notselect
lda editbuffer1 lda editbuffer1
@@ -292,30 +303,36 @@ notstart:lda controlsedge
sta AUDIO_BASE+13 sta AUDIO_BASE+13
lda editbuffer1+7 lda editbuffer1+7
sta AUDIO_BASE+7 sta AUDIO_BASE+7
notselect:lda controlsedge notselect:
lda controlsedge
and #JOY_DATA_FIRE_A and #JOY_DATA_FIRE_A
bne notbuttona bne notbuttona
ldy #0 ldy #0
ldy #0 ldy #0
writea:lda editbuffer1,y writea:
lda editbuffer1,y
sta (writeaddr),y sta (writeaddr),y
iny iny
cpy #8 cpy #8
bne writea bne writea
writeb:lda editbuffer2-8,y writeb:
lda editbuffer2-8,y
sta (writeaddr),y sta (writeaddr),y
iny iny
cpy #16 cpy #16
bne writeb bne writeb
notbuttona:lda controlsedge notbuttona:
lda controlsedge
and #JOY_DATA_FIRE_B and #JOY_DATA_FIRE_B
bne notbuttonb bne notbuttonb
ldy #0 ldy #0
reada:lda (readaddr),y reada:
lda (readaddr),y
sta editbuffer1,y sta editbuffer1,y
iny iny
cpy #8 cpy #8
bne reada bne reada
readb: lda (readaddr),y readb: lda (readaddr),y
sta editbuffer2-8,y sta editbuffer2-8,y
iny iny
@@ -437,4 +454,3 @@ printsign1:
ldy temp_y ldy temp_y
rts rts
.endproc .endproc

View File

@@ -1,5 +1,8 @@
;
; original lcdtest.s by PeT (mess@utanet.at) ; original lcdtest.s by PeT (mess@utanet.at)
;
; cl65 -t gamate -o lcdtest.bin lcdtest.s
;
.include "gamate.inc" .include "gamate.inc"
@@ -7,7 +10,7 @@
addr: .word 0 addr: .word 0
psa: .word 0 psa: .word 0
.data .bss
temp_x: .byte 0 temp_x: .byte 0
temp_y: .byte 0 temp_y: .byte 0
temp_a: .byte 0 temp_a: .byte 0
@@ -20,16 +23,17 @@ counted: .word 0
xpos: .byte 0 xpos: .byte 0
ypos: .byte 0 ypos: .byte 0
.code .rodata
chars: chars: .incbin "cga2.chr"
.incbin "cga2.chr"
hex2asc: .byte "0123456789abcdef" hex2asc: .byte "0123456789abcdef"
format: .byte "IrqNmiCountXposYpos", 0 format: .byte "IrqNmiCountXposYpos", 0
xdesc: .byte "0123456789abcdefghijklmnopqrstuv", 0 xdesc: .byte "0123456789abcdefghijklmnopqrstuv", 0
ydesc: .byte "0123456789ABCDEFGHIJKLMNOPQRSTUV", 0 ydesc: .byte "0123456789ABCDEFGHIJKLMNOPQRSTUV", 0
.code
;------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------
.export IRQStub, NMIStub .export IRQStub, NMIStub
@@ -57,6 +61,9 @@ ydesc: .byte "0123456789ABCDEFGHIJKLMNOPQRSTUV", 0
.export Start .export Start
.proc Start .proc Start
sei
lda #0
sta ZP_IRQ_CTRL
lda #0 lda #0
sta LCD_XPOS sta LCD_XPOS
@@ -87,8 +94,7 @@ ydesc: .byte "0123456789ABCDEFGHIJKLMNOPQRSTUV", 0
sty LCD_Y sty LCD_Y
jsr printstringy jsr printstringy
; lda #$90;(LCD_XPOS_PLANE2|(128/8)) lda #(LCD_XPOS_PLANE2|(128/8)) ; ???
lda #(LCD_XPOS_PLANE2|(128/8))
sta LCD_X sta LCD_X
lda #<ydesc lda #<ydesc
ldx #>ydesc ldx #>ydesc
@@ -109,6 +115,7 @@ ydesc: .byte "0123456789ABCDEFGHIJKLMNOPQRSTUV", 0
sta LCD_Y sta LCD_Y
lda #'X' lda #'X'
jsr printsign jsr printsign
lda #$80 lda #$80
sta LCD_MODE sta LCD_MODE
lda #32/8 lda #32/8
@@ -117,6 +124,7 @@ ydesc: .byte "0123456789ABCDEFGHIJKLMNOPQRSTUV", 0
sta LCD_Y sta LCD_Y
lda #'Y' lda #'Y'
jsr printsign jsr printsign
lda #$c0 lda #$c0
sta LCD_MODE sta LCD_MODE
lda #40/8 lda #40/8
@@ -134,6 +142,7 @@ ydesc: .byte "0123456789ABCDEFGHIJKLMNOPQRSTUV", 0
sta LCD_Y sta LCD_Y
lda #'x' lda #'x'
jsr printsign jsr printsign
lda #$80 lda #$80
sta LCD_MODE sta LCD_MODE
lda #(LCD_XPOS_PLANE2|(56/8)) lda #(LCD_XPOS_PLANE2|(56/8))
@@ -142,6 +151,7 @@ ydesc: .byte "0123456789ABCDEFGHIJKLMNOPQRSTUV", 0
sta LCD_Y sta LCD_Y
lda #'y' lda #'y'
jsr printsign jsr printsign
lda #$c0 lda #$c0
sta LCD_MODE sta LCD_MODE
lda #(LCD_XPOS_PLANE2|(64/8)) lda #(LCD_XPOS_PLANE2|(64/8))
@@ -159,6 +169,7 @@ ydesc: .byte "0123456789ABCDEFGHIJKLMNOPQRSTUV", 0
sta LCD_Y sta LCD_Y
lda #'V' lda #'V'
jsr printsign jsr printsign
lda #LCD_MODE_INC_Y|2 lda #LCD_MODE_INC_Y|2
sta LCD_MODE sta LCD_MODE
lda #24/8 lda #24/8
@@ -167,6 +178,7 @@ ydesc: .byte "0123456789ABCDEFGHIJKLMNOPQRSTUV", 0
sta LCD_Y sta LCD_Y
lda #'V' lda #'V'
jsr printsign jsr printsign
lda #LCD_MODE_INC_Y|4 lda #LCD_MODE_INC_Y|4
sta LCD_MODE sta LCD_MODE
lda #32/8 lda #32/8
@@ -175,6 +187,7 @@ ydesc: .byte "0123456789ABCDEFGHIJKLMNOPQRSTUV", 0
sta LCD_Y sta LCD_Y
lda #'V' lda #'V'
jsr printsign jsr printsign
lda #LCD_MODE_INC_Y|8 lda #LCD_MODE_INC_Y|8
sta LCD_MODE sta LCD_MODE
lda #40/8 lda #40/8
@@ -184,28 +197,28 @@ ydesc: .byte "0123456789ABCDEFGHIJKLMNOPQRSTUV", 0
lda #'V' lda #'V'
jsr printsign jsr printsign
lda #1 lda #1
sta ZP_NMI_ENABLE sta ZP_IRQ_CTRL
loop: lda count loop:
lda count
clc clc
adc #1 adc #1
sta count sta count
lda count+1 lda count+1
adc #1 adc #0
sta count+1 sta count+1
lda irq_count lda irq_count
cmp irq_count cmp irq_count
beq loop beq loop
jsr inputs jsr inputs
lda #LCD_MODE_INC_Y lda #LCD_MODE_INC_Y
sta LCD_MODE sta LCD_MODE
jsr printy jsr printy
jmp loop jmp loop
.endproc .endproc
@@ -250,37 +263,45 @@ loop: lda count
dec ypos dec ypos
lda ypos lda ypos
sta LCD_YPOS sta LCD_YPOS
notup:lda JOY_DATA notup:
lda JOY_DATA
and #JOY_DATA_DOWN and #JOY_DATA_DOWN
bne notdown bne notdown
inc ypos inc ypos
lda ypos lda ypos
sta LCD_YPOS sta LCD_YPOS
notdown:lda JOY_DATA notdown:
lda JOY_DATA
and #JOY_DATA_LEFT and #JOY_DATA_LEFT
bne notleft bne notleft
dec xpos dec xpos
lda xpos lda xpos
sta LCD_XPOS sta LCD_XPOS
notleft:lda JOY_DATA notleft:
lda JOY_DATA
and #JOY_DATA_RIGHT and #JOY_DATA_RIGHT
bne notright bne notright
inc xpos inc xpos
lda xpos lda xpos
sta LCD_XPOS sta LCD_XPOS
notright:lda JOY_DATA notright:
lda JOY_DATA
and #JOY_DATA_START and #JOY_DATA_START
bne notstart bne notstart
notstart:lda JOY_DATA notstart:
lda JOY_DATA
and #JOY_DATA_SELECT and #JOY_DATA_SELECT
bne notselect bne notselect
notselect:lda JOY_DATA notselect:
lda JOY_DATA
and #JOY_DATA_FIRE_A and #JOY_DATA_FIRE_A
bne notbuttona bne notbuttona
notbuttona:lda JOY_DATA notbuttona:
lda JOY_DATA
and #JOY_DATA_FIRE_B and #JOY_DATA_FIRE_B
bne notbuttonb bne notbuttonb
notbuttonb:rts notbuttonb:
rts
.endproc .endproc
;------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------