}
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__;
}
+++ /dev/null
-;
-; 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
; This must be the *first* file on the linker command line
;
- .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
- .import __BSS_SIZE__
-
- .include "pce.inc"
-
- .importzp sp
- .importzp ptr1,ptr2
+ .export _exit
+ .export __STARTUP__ : absolute = 1 ; Mark as startup
+
+ .import initlib, donelib
+ .import push0, _main, zerobss
+ .import initheap
+ .import tmp1,tmp2,tmp3
+
+ ; 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"
+
+ .importzp sp
+ .importzp ptr1,ptr2
; ------------------------------------------------------------------------
; 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:
sei
nop
- csh ; set high speed CPU mode
+ csh ; set high speed CPU mode
nop
cld
nop
; Setup stack and memory mapping
- ldx #$FF ; Stack top ($21FF)
+ ldx #$FF ; Stack top ($21FF)
txs
; 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
.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
- jsr zerobss
-
-; 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__)
+ ; Copy the .data segment to RAM
+ lda #<(__DATA_LOAD__)
+ sta ptr1
+ lda #>(__DATA_LOAD__)
+ sta ptr1+1
+ lda #<(__DATA_RUN__)
+ sta ptr2
+ lda #>(__DATA_RUN__)
+ sta ptr2+1
+ ldx #>(__DATA_SIZE__)
@l2:
- beq @s1 ; no more full pages
+ beq @s1 ; no more full pages
- ; copy one page
- ldy #0
+ ; copy one page
+ ldy #0
@l1:
- lda (ptr1),y
- sta (ptr2),y
- iny
- bne @l1
+ lda (ptr1),y
+ sta (ptr2),y
+ iny
+ bne @l1
- inc ptr1+1
- inc ptr2+1
+ inc ptr1+1
+ inc ptr2+1
- dex
- bne @l2
+ dex
+ bne @l2
- ; copy remaining bytes
+ ; copy remaining bytes
@s1:
-
- ; copy one page
- ldy #0
+ ; copy one page
+ ldy #0
@l3:
- lda (ptr1),y
- sta (ptr2),y
- iny
- cpy #<(__DATA_SIZE__)
- bne @l3
-
-; setup the stack
+ lda (ptr1),y
+ sta (ptr2),y
+ iny
+ cpy #<(__DATA_SIZE__)
+ bne @l3
-; lda #<(__RAM_START__ + __DATA_SIZE__ + __BSS_SIZE__)
- 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
+ ; setup the stack
+ lda #<(__RAM_START__+__RAM_SIZE__)
+ sta sp
+ lda #>(__RAM_START__+__RAM_SIZE__)
+ sta sp+1
-; Init the Heap
- jsr initheap
+ ; Init the Heap
+ jsr initheap
-;jmp *
+ ; Call module constructors
+ jsr initlib
-; Call module constructors
+ ;; FIXME: this should be called from a constructor instead
+ .import initconio
+ jsr initconio
- jsr initlib
+ ; Pass an empty command line
+ jsr push0 ; argc
+ jsr push0 ; argv
- ;; FIXME: this should be called from a constructor instead
- .import initconio
- jsr initconio
-
-; Pass an empty command line
-
-
-;jmp *
-
- 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.
+ ldy #4 ; Argument size
+ jsr _main ; call the users code
+ ; Call module destructors. This is also the _exit entry.
_exit:
- jsr donelib ; Run module destructors
-
-; reset the PCEngine
+ jsr donelib ; Run module destructors
- jmp start
+ ; reset the PCEngine (start over)
+ jmp start
; ------------------------------------------------------------------------
; System V-Blank Interupt
+; FIXME: hooks should be provided so the user can abuse the IRQ
; ------------------------------------------------------------------------
_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
; ------------------------------------------------------------------------
; 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
-
-
+ .segment "VECTORS"
+ .word _irq2 ; $fff6 IRQ2 (External IRQ, BRK)
+ .word _irq1 ; $fff8 IRQ1 (VDC)
+ .word _timer ; $fffa Timer
+ .word _nmi ; $fffc NMI
+ .word start ; $fffe reset
+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
--------------------------------------------------------------------------------
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
\ No newline at end of file