mirror of
https://github.com/cc65/cc65.git
synced 2024-12-28 06:30:16 +00:00
more cleanup and fixing
This commit is contained in:
parent
891cb97b2f
commit
9e1d39a409
@ -11,7 +11,7 @@ CRAM_PTR = $34 ;2
|
||||
CHARCOLOR = $36
|
||||
RVS = $37
|
||||
BGCOLOR = $38
|
||||
_tickcount = $39 ;2
|
||||
_tickcount = $39 ;4
|
||||
|
||||
screenrows = (224/8)
|
||||
charsperline = (512/8)
|
||||
@ -74,11 +74,13 @@ CDR_MEM_ENABLE = $1807
|
||||
.byte $ad
|
||||
.word arg1
|
||||
.endmacro
|
||||
|
||||
;; sta abs
|
||||
.macro staio arg1
|
||||
.byte $8d
|
||||
.word arg1
|
||||
.endmacro
|
||||
|
||||
;; stz abs
|
||||
.macro stzio arg1
|
||||
.byte $9c
|
||||
|
23
cfg/pce.cfg
23
cfg/pce.cfg
@ -28,13 +28,18 @@ SEGMENTS {
|
||||
}
|
||||
|
||||
FEATURES {
|
||||
CONDES: segment = STARTUP,
|
||||
type=constructor,
|
||||
label=__CONSTRUCTOR_TABLE__,
|
||||
count=__CONSTRUCTOR_COUNT__;
|
||||
|
||||
CONDES: segment = STARTUP,
|
||||
type=destructor,
|
||||
label=__DESTRUCTOR_TABLE__,
|
||||
count=__DESTRUCTOR_COUNT__;
|
||||
CONDES: type = constructor,
|
||||
label = __CONSTRUCTOR_TABLE__,
|
||||
count = __CONSTRUCTOR_COUNT__,
|
||||
segment = INIT;
|
||||
CONDES: type = destructor,
|
||||
label = __DESTRUCTOR_TABLE__,
|
||||
count = __DESTRUCTOR_COUNT__,
|
||||
segment = RODATA;
|
||||
# FIXME: interruptor support is missing
|
||||
# CONDES: type = interruptor,
|
||||
# label = __INTERRUPTOR_TABLE__,
|
||||
# count = __INTERRUPTOR_COUNT__,
|
||||
# segment = RODATA,
|
||||
# import = __CALLIRQ__;
|
||||
}
|
||||
|
@ -28,13 +28,9 @@
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
#ifndef _PCE_H
|
||||
#define _PCE_H
|
||||
|
||||
|
||||
|
||||
/* Check for errors */
|
||||
#if !defined(__PCE__)
|
||||
# error This module may only be used when compiling for the PCE!
|
||||
@ -69,8 +65,8 @@
|
||||
#define COLOR_LIGHTBLUE 0x0E
|
||||
#define COLOR_GRAY3 0x0F
|
||||
|
||||
#define CLOCKS_PER_SEC 50 // ???
|
||||
#define CLK_TCK 50 // ?!?
|
||||
#define CLOCKS_PER_SEC 50 // FIXME: is this correct?
|
||||
#define CLK_TCK 50 // FIXME: is this correct?
|
||||
|
||||
#define TV_NTSC 0
|
||||
#define TV_PAL 1
|
||||
|
@ -1,17 +0,0 @@
|
||||
;
|
||||
; CC65 runtime: call function via pointer in ax
|
||||
;
|
||||
|
||||
.export callax
|
||||
|
||||
.code
|
||||
|
||||
callax:
|
||||
sta vec
|
||||
stx vec+1
|
||||
jmp (vec) ; jump there
|
||||
|
||||
.bss
|
||||
|
||||
vec:
|
||||
.res 2
|
@ -9,10 +9,10 @@
|
||||
|
||||
.proc _clock
|
||||
|
||||
ldy #0 ; Byte 3 is always zero
|
||||
sty sreg+1
|
||||
sty sreg
|
||||
|
||||
lda _tickcount+3
|
||||
sta sreg+1
|
||||
lda _tickcount+2
|
||||
sta sreg
|
||||
ldx _tickcount+1
|
||||
lda _tickcount
|
||||
rts
|
||||
|
@ -1,96 +0,0 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 20.11.2000
|
||||
;
|
||||
; CC65 runtime: Support for calling module constructors/destructors
|
||||
;
|
||||
; The condes routine must be called with the table address in a/x and the
|
||||
; size of the table in y. The current implementation limits the table size
|
||||
; to 254 bytes (127 vectors) but this shouldn't be problem for now and may
|
||||
; be changed later.
|
||||
;
|
||||
; libinit and libdone call condes with the predefined module constructor and
|
||||
; destructor tables, they must be called from the platform specific startup
|
||||
; code.
|
||||
|
||||
|
||||
.export initlib, donelib, condes
|
||||
|
||||
.import callax
|
||||
.import __CONSTRUCTOR_TABLE__, __CONSTRUCTOR_COUNT__
|
||||
.import __DESTRUCTOR_TABLE__, __DESTRUCTOR_COUNT__
|
||||
|
||||
|
||||
|
||||
.code
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Initialize library modules
|
||||
|
||||
.proc initlib
|
||||
|
||||
lda #<__CONSTRUCTOR_TABLE__
|
||||
ldx #>__CONSTRUCTOR_TABLE__
|
||||
ldy #<(__CONSTRUCTOR_COUNT__*2)
|
||||
bne condes
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Cleanup library modules
|
||||
|
||||
.proc donelib
|
||||
|
||||
lda #<__DESTRUCTOR_TABLE__
|
||||
ldx #>__DESTRUCTOR_TABLE__
|
||||
ldy #<(__DESTRUCTOR_COUNT__*2)
|
||||
bne condes
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Generic table call handler
|
||||
|
||||
.proc condes
|
||||
|
||||
sta getbyt+1
|
||||
stx getbyt+2
|
||||
sty index
|
||||
|
||||
loop: ldy index
|
||||
beq done
|
||||
dey
|
||||
jsr getbyt
|
||||
tax
|
||||
dey
|
||||
jsr getbyt
|
||||
sty index
|
||||
jsr callax
|
||||
.ifpc02
|
||||
bra loop
|
||||
.else
|
||||
jmp loop
|
||||
.endif
|
||||
|
||||
done: rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; Data. The getbyte routine is placed in the data segment cause it's patched
|
||||
; at runtime.
|
||||
|
||||
.bss
|
||||
|
||||
index: .byte 0
|
||||
|
||||
.data
|
||||
|
||||
getbyt:
|
||||
;;getbyt_:
|
||||
lda $FFFF,y
|
||||
rts
|
@ -5,7 +5,6 @@
|
||||
.import vdc_init
|
||||
|
||||
.export initconio
|
||||
.export _conio_init
|
||||
|
||||
.constructor initconio, 24
|
||||
|
||||
@ -46,8 +45,6 @@ set_palette:
|
||||
stz VCE_DATA_LO
|
||||
stz VCE_DATA_HI
|
||||
|
||||
; so it will get linked in
|
||||
_conio_init:
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
|
@ -9,19 +9,20 @@
|
||||
|
||||
.export _exit
|
||||
.export __STARTUP__ : absolute = 1 ; Mark as startup
|
||||
|
||||
.import initlib, donelib
|
||||
.import push0, _main, zerobss
|
||||
.import initheap
|
||||
.import tmp1,tmp2,tmp3
|
||||
|
||||
.import __RAM_START__, __RAM_SIZE__ ; Linker generated
|
||||
;; .import __SRAM_START__, __SRAM_SIZE__ ; Linker generated
|
||||
.import __ROM0_START__, __ROM0_SIZE__ ; Linker generated
|
||||
.import __ROM_START__, __ROM_SIZE__ ; Linker generated
|
||||
.import __STARTUP_LOAD__,__STARTUP_RUN__, __STARTUP_SIZE__ ; Linker generated
|
||||
.import __CODE_LOAD__,__CODE_RUN__, __CODE_SIZE__ ; Linker generated
|
||||
.import __RODATA_LOAD__,__RODATA_RUN__, __RODATA_SIZE__ ; Linker generated
|
||||
.import __DATA_LOAD__,__DATA_RUN__, __DATA_SIZE__ ; Linker generated
|
||||
; Linker generated
|
||||
.import __RAM_START__, __RAM_SIZE__
|
||||
.import __ROM0_START__, __ROM0_SIZE__
|
||||
.import __ROM_START__, __ROM_SIZE__
|
||||
.import __STARTUP_LOAD__,__STARTUP_RUN__, __STARTUP_SIZE__
|
||||
.import __CODE_LOAD__,__CODE_RUN__, __CODE_SIZE__
|
||||
.import __RODATA_LOAD__,__RODATA_RUN__, __RODATA_SIZE__
|
||||
.import __DATA_LOAD__,__DATA_RUN__, __DATA_SIZE__
|
||||
.import __BSS_SIZE__
|
||||
|
||||
.include "pce.inc"
|
||||
@ -32,12 +33,12 @@
|
||||
; ------------------------------------------------------------------------
|
||||
; Create an empty LOWCODE segment to avoid linker warnings
|
||||
|
||||
.segment "LOWCODE"
|
||||
.segment "LOWCODE"
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Place the startup code in a special segment.
|
||||
|
||||
.segment "STARTUP"
|
||||
.segment "STARTUP"
|
||||
|
||||
start:
|
||||
|
||||
@ -58,21 +59,21 @@ start:
|
||||
|
||||
; at startup all MPRs are set to 0, so init them
|
||||
lda #$ff
|
||||
tam #1 ; 0000-1FFF = Hardware page
|
||||
tam #%00000001 ; 0000-1FFF = Hardware page
|
||||
lda #$F8
|
||||
tam #2 ; 2000-3FFF = Work RAM
|
||||
tam #%00000010 ; 2000-3FFF = Work RAM
|
||||
;lda #$F7
|
||||
;tam #2 ; 4000-5FFF = Save RAM
|
||||
;tam #%00000100 ; 4000-5FFF = Save RAM
|
||||
;lda #1
|
||||
;tam #3 ; 6000-7FFF Page 2
|
||||
;tam #%00001000 ; 6000-7FFF Page 2
|
||||
;lda #2
|
||||
;tam #4 ; 8000-9FFF Page 3
|
||||
;tam #%00010000 ; 8000-9FFF Page 3
|
||||
;lda #3
|
||||
;tam #5 ; A000-BFFF Page 4
|
||||
;tam #%00100000 ; A000-BFFF Page 4
|
||||
;lda #4
|
||||
;tam #6 ; C000-DFFF Page 5
|
||||
;tam #%01000000 ; C000-DFFF Page 5
|
||||
;lda #0
|
||||
;tam #7 ; e000-fFFF hucard/syscard bank 0
|
||||
;tam #%10000000 ; e000-fFFF hucard/syscard bank 0
|
||||
|
||||
; Clear work RAM (2000-3FFF)
|
||||
stz <$00
|
||||
@ -88,37 +89,26 @@ start:
|
||||
.import vdc_init
|
||||
jsr vdc_init
|
||||
|
||||
;; jsr joy_init
|
||||
|
||||
; Turn on background and VD interrupt/IRQ1
|
||||
|
||||
lda #$05
|
||||
sta IRQ_MASK ; IRQ1=on
|
||||
|
||||
cli
|
||||
|
||||
; Clear the BSS data
|
||||
|
||||
; Clear the BSS data
|
||||
jsr zerobss
|
||||
|
||||
; Copy the .data segment to RAM
|
||||
|
||||
; Copy the .data segment to RAM
|
||||
lda #<(__DATA_LOAD__)
|
||||
;;lda #<(__ROM0_START__ + __STARTUP_SIZE__+ __CODE_SIZE__+ __RODATA_SIZE__)
|
||||
;;lda #<(__ROM_START__ + __CODE_SIZE__+ __RODATA_SIZE__)
|
||||
sta ptr1
|
||||
lda #>(__DATA_LOAD__)
|
||||
;;lda #>(__ROM_START__ + __CODE_SIZE__+ __RODATA_SIZE__)
|
||||
sta ptr1+1
|
||||
lda #<(__DATA_RUN__)
|
||||
;;lda #<(__SRAM_START__)
|
||||
sta ptr2
|
||||
lda #>(__DATA_RUN__)
|
||||
;;lda #>(__SRAM_START__)
|
||||
sta ptr2+1
|
||||
|
||||
ldx #>(__DATA_SIZE__)
|
||||
|
||||
@l2:
|
||||
beq @s1 ; no more full pages
|
||||
|
||||
@ -138,7 +128,6 @@ start:
|
||||
|
||||
; copy remaining bytes
|
||||
@s1:
|
||||
|
||||
; copy one page
|
||||
ldy #0
|
||||
@l3:
|
||||
@ -148,50 +137,39 @@ start:
|
||||
cpy #<(__DATA_SIZE__)
|
||||
bne @l3
|
||||
|
||||
; setup the stack
|
||||
|
||||
; lda #<(__RAM_START__ + __DATA_SIZE__ + __BSS_SIZE__)
|
||||
; setup the stack
|
||||
lda #<(__RAM_START__+__RAM_SIZE__)
|
||||
sta sp
|
||||
; lda #>(__RAM_START__ + __DATA_SIZE__ + __BSS_SIZE__)
|
||||
lda #>(__RAM_START__+__RAM_SIZE__)
|
||||
sta sp+1 ; Set argument stack ptr
|
||||
sta sp+1
|
||||
|
||||
; Init the Heap
|
||||
; Init the Heap
|
||||
jsr initheap
|
||||
|
||||
;jmp *
|
||||
|
||||
; Call module constructors
|
||||
|
||||
; Call module constructors
|
||||
jsr initlib
|
||||
|
||||
;; FIXME: this should be called from a constructor instead
|
||||
.import initconio
|
||||
jsr initconio
|
||||
|
||||
; Pass an empty command line
|
||||
|
||||
|
||||
;jmp *
|
||||
|
||||
; Pass an empty command line
|
||||
jsr push0 ; argc
|
||||
jsr push0 ; argv
|
||||
go:
|
||||
|
||||
ldy #4 ; Argument size
|
||||
jsr _main ; call the users code
|
||||
|
||||
; Call module destructors. This is also the _exit entry.
|
||||
|
||||
; Call module destructors. This is also the _exit entry.
|
||||
_exit:
|
||||
jsr donelib ; Run module destructors
|
||||
|
||||
; reset the PCEngine
|
||||
|
||||
; reset the PCEngine (start over)
|
||||
jmp start
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; System V-Blank Interupt
|
||||
; FIXME: hooks should be provided so the user can abuse the IRQ
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
_irq1:
|
||||
@ -201,10 +179,13 @@ _irq1:
|
||||
|
||||
|
||||
inc _tickcount
|
||||
bne @s
|
||||
bne @s1
|
||||
inc _tickcount+1
|
||||
@s:
|
||||
|
||||
bne @s1
|
||||
inc _tickcount+2
|
||||
bne @s1
|
||||
inc _tickcount+3
|
||||
@s1:
|
||||
; Acknowlege interrupt
|
||||
ldaio VDC_CTRL
|
||||
|
||||
@ -228,13 +209,9 @@ initmainargs:
|
||||
; hardware vectors
|
||||
; ------------------------------------------------------------------------
|
||||
.segment "VECTORS"
|
||||
;;.org $fff6
|
||||
|
||||
.word _irq2 ; $fff6 IRQ2 (External IRQ, BRK)
|
||||
.word _irq1 ; $fff8 IRQ1 (VDC)
|
||||
.word _timer ; $fffa Timer
|
||||
.word _nmi ; $fffc NMI
|
||||
.word start ; $fffe reset
|
||||
|
||||
|
||||
|
||||
|
@ -25,11 +25,6 @@
|
||||
|
||||
; Button state masks (8 values)
|
||||
|
||||
;extern const unsigned char joy_masks[8];
|
||||
|
||||
.export _joy_masks
|
||||
|
||||
_joy_masks:
|
||||
.byte $10 ; JOY_UP
|
||||
.byte $40 ; JOY_DOWN
|
||||
.byte $80 ; JOY_LEFT
|
||||
|
@ -1,19 +1,23 @@
|
||||
PC-Engine (PCE) target support for cc65. this is still work in progress and
|
||||
a couple of things need to be fixed:
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
joystick support should get verified on real hw, the masks for buttons may be
|
||||
wrong.
|
||||
|
||||
clock() does not work for unknown reasons
|
||||
|
||||
get_tv() is a dummy function and always returns 0
|
||||
joystick support should get verified on real hw
|
||||
- the masks for buttons may be wrong.
|
||||
- 6 button gamepads are different and need slightly different code
|
||||
|
||||
revers() is a dummy function, actual reverse output is not supported yet
|
||||
|
||||
waitvblank() is missing
|
||||
get_tv() is missing
|
||||
|
||||
some graphical petscii chars should get added to the charset
|
||||
|
||||
conio-init should get initialized from a constructor rather than always get
|
||||
called from crt0
|
||||
called from crt0 (which for some reason doesnt work) -> see conio.s, it should
|
||||
get linked if _any_ of the conio function is used
|
||||
|
||||
interruptor support in crt0 (and cfg) is missing
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -29,3 +33,16 @@ w/s/a/d up/down/left/right
|
||||
numpad 2 (?) button
|
||||
numpad 3 (?) button
|
||||
enter (start) button
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
some useful resources on PCE coding:
|
||||
|
||||
http://blog.blockos.org/?tag=pc-engine
|
||||
http://pcedev.blockos.org/viewforum.php?f=5
|
||||
http://www.romhacking.net/?page=documents&category=&platform=4&game=&author=&perpage=20&level=&title=&desc=&docsearch=Go
|
||||
http://archaicpixels.com/Main_Page
|
||||
|
||||
http://www.magicengine.com/mkit/doc.html
|
||||
|
||||
https://github.com/uli/huc
|
||||
http://www.zeograd.com/parse.php?src=hucf
|
12
testcode/lib/pce/Makefile
Normal file
12
testcode/lib/pce/Makefile
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
all: conio.pce
|
||||
|
||||
conio.pce: conio.c
|
||||
../../../bin/cl65 -t pce conio.c ../../../joy/pce-stdjoy.joy --mapfile conio.map -o conio.pce
|
||||
|
||||
clean:
|
||||
$(RM) conio.pce
|
||||
|
||||
test: conio.pce
|
||||
mednafen -force_module pce conio.pce
|
||||
|
@ -9,6 +9,7 @@ void main(void)
|
||||
{
|
||||
int stackvar = 42;
|
||||
int i, j;
|
||||
clock_t clk;
|
||||
|
||||
joy_install(&joy_static_stddrv);
|
||||
|
||||
@ -39,7 +40,9 @@ void main(void)
|
||||
++datavar; ++stackvar;
|
||||
|
||||
gotoxy(0,8);
|
||||
cprintf("clock: %08x", clock());
|
||||
clk = clock();
|
||||
cprintf("clock: %08lx", clk);
|
||||
|
||||
for (i = 0; i < 4; ++i)
|
||||
{
|
||||
gotoxy(0, 12 + i);
|
||||
|
Loading…
Reference in New Issue
Block a user