1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-09 06:29:38 +00:00

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_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

View File

@ -8,7 +8,8 @@ SYMBOLS {
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;

View File

@ -41,7 +41,8 @@
/*
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
@ -132,6 +133,26 @@
#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

View File

@ -103,8 +103,8 @@ unsigned _clocks_per_sec (void);
# 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 */

View File

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

View File

@ -65,16 +65,6 @@ plot: ldy CURS_X
; 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
@ -139,8 +129,6 @@ putchar:
bne @copylp2
@skip_plane2:
pla
tax
ldy CURS_X

View File

@ -17,8 +17,12 @@ Start:
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
@ -36,6 +40,8 @@ Start:
; 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

View File

@ -1,7 +1,7 @@
;
; 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.

View File

@ -1,5 +1,5 @@
;
; Groepaz/Hitmen, 2015-11-19
; Groepaz/Hitmen, 2015-11-27
;
; 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?)
IRQStub:
pha
tya
pha
; A and Y are saved by the BIOS
;pha
;tya
;pha
ldy #<(__INTERRUPTOR_COUNT__ * 2)
beq @L1
@ -45,7 +46,7 @@ IRQStub:
pla
tax
@L1: pla
tay
pla
@L1: ;pla
;tay
;pla
rts

View File

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

View File

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

View File

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