mirror of
https://github.com/cc65/cc65.git
synced 2025-01-10 19:29:45 +00:00
Merge branch 'master' of https://github.com/jedeoric/cc65
This commit is contained in:
commit
aaf8863de5
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
||||
* text=auto
|
@ -6,13 +6,9 @@ install:
|
||||
script:
|
||||
- make bin USER_CFLAGS=-Werror
|
||||
- make lib QUIET=1
|
||||
- make -C test
|
||||
- make -C test QUIET=1
|
||||
- make -C src clean
|
||||
- make bin USER_CFLAGS=-Werror CROSS_COMPILE=i686-w64-mingw32-
|
||||
- make doc zip
|
||||
after_success:
|
||||
- make -f Makefile.travis
|
||||
env:
|
||||
global:
|
||||
- secure: "h+hoQdEHGPLNwaqGKmSaM8NBRDLc2X+W05VsnNG2Feq/wPv/AiBjONNlzN7jRf6D6f3aoPXaQ2Lc3bYWdxGvFRCmwiofdxkJI9n5L8HPHLZ2lf37MQsXmGJzoTFOvjPLj73H6HlbI9Ux0El3zO6hvalxiXj6TfoZ41dbhNyvpYk="
|
||||
- secure: "A4hMEe5RRfUtYjFGbT7QAvT1Tyo434N+/TiuQeQ4q0L46c79LnXuGQzbFLOFZshZiplLkJr7lFg466CoI1bf2L0cQOew/LesMhE75v0HQ7tZnExWhdpAk0ri6nWixbjn/dmQ0+HxjzJ48A44DMMBYcvSIsO4vflvuJ8etfSg42k="
|
||||
|
4
Makefile
4
Makefile
@ -1,4 +1,4 @@
|
||||
.PHONY: all mostlyclean clean install zip avail unavail bin lib doc samples
|
||||
.PHONY: all mostlyclean clean install zip avail unavail bin lib doc html info samples
|
||||
|
||||
.SUFFIXES:
|
||||
|
||||
@ -14,7 +14,7 @@ avail unavail bin:
|
||||
lib:
|
||||
@$(MAKE) -C libsrc --no-print-directory $@
|
||||
|
||||
doc:
|
||||
doc html info:
|
||||
@$(MAKE) -C doc --no-print-directory $@
|
||||
|
||||
samples:
|
||||
|
@ -8,42 +8,42 @@
|
||||
; ATASCII CHARACTER DEFS
|
||||
;-------------------------------------------------------------------------
|
||||
|
||||
ATEOL = $9B ;END-OF-LINE, used by CONIO
|
||||
ATEOL = $9B ; END-OF-LINE, used by CONIO
|
||||
|
||||
|
||||
;-------------------------------------------------------------------------
|
||||
; Zero Page
|
||||
;-------------------------------------------------------------------------
|
||||
|
||||
POKMSK = $00 ;Mask for Pokey IRQ enable
|
||||
RTCLOK = $01 ;60 hz. clock
|
||||
POKMSK = $00 ; Mask for Pokey IRQ enable
|
||||
RTCLOK = $01 ; 60 hz. clock
|
||||
JUMP = $01
|
||||
CRITIC = $03 ;Critical section
|
||||
ATRACT = $04 ;Attract Mode
|
||||
CRITIC = $03 ; Critical section
|
||||
ATRACT = $04 ; Attract Mode
|
||||
|
||||
SDLSTL = $05 ;DLISTL Shadow
|
||||
SDLSTH = $06 ;DLISTH "
|
||||
SDMCTL = $07 ;DMACTL "
|
||||
SDLSTL = $05 ; DLISTL Shadow
|
||||
SDLSTH = $06 ; DLISTH "
|
||||
SDMCTL = $07 ; DMACTL "
|
||||
|
||||
PCOLR0 = $08 ;COLPM0 Shadow
|
||||
PCOLR1 = $09 ;COLPM1 "
|
||||
PCOLR2 = $0A ;COLPM2 "
|
||||
PCOLR3 = $0B ;COLPM3 "
|
||||
PCOLR0 = $08 ; COLPM0 Shadow
|
||||
PCOLR1 = $09 ; COLPM1 "
|
||||
PCOLR2 = $0A ; COLPM2 "
|
||||
PCOLR3 = $0B ; COLPM3 "
|
||||
|
||||
COLOR0 = $0C ;COLPF0 Shadow
|
||||
COLOR1 = $0D ;COLPF1 "
|
||||
COLOR2 = $0E ;COLPF2 "
|
||||
COLOR3 = $0F ;COLPF3 "
|
||||
COLOR4 = $10 ;COLBK "
|
||||
COLOR0 = $0C ; COLPF0 Shadow
|
||||
COLOR1 = $0D ; COLPF1 "
|
||||
COLOR2 = $0E ; COLPF2 "
|
||||
COLOR3 = $0F ; COLPF3 "
|
||||
COLOR4 = $10 ; COLBK "
|
||||
|
||||
PADDL0 = $11 ;POT0 Shadow
|
||||
PADDL1 = $12 ;POT1 "
|
||||
PADDL2 = $13 ;POT2 "
|
||||
PADDL3 = $14 ;POT3 "
|
||||
PADDL4 = $15 ;POT4 "
|
||||
PADDL5 = $16 ;POT5 "
|
||||
PADDL6 = $17 ;POT6 "
|
||||
PADDL7 = $18 ;POT7 "
|
||||
PADDL0 = $11 ; POT0 Shadow
|
||||
PADDL1 = $12 ; POT1 "
|
||||
PADDL2 = $13 ; POT2 "
|
||||
PADDL3 = $14 ; POT3 "
|
||||
PADDL4 = $15 ; POT4 "
|
||||
PADDL5 = $16 ; POT5 "
|
||||
PADDL6 = $17 ; POT6 "
|
||||
PADDL7 = $18 ; POT7 "
|
||||
|
||||
; cc65 runtime zero page variables
|
||||
|
||||
@ -57,26 +57,26 @@ SAVMSC = $1B ; pointer to screen memory (conio)
|
||||
|
||||
;Interrupt Vectors
|
||||
|
||||
VIMIRQ = $0200 ;Immediate IRQ
|
||||
;Preset $FC03 (SYSIRQ)
|
||||
VVBLKI = $0202 ;Vblank immediate
|
||||
;Preset $FCB8 (SYSVBL)
|
||||
VVBLKD = $0204 ;Vblank deferred
|
||||
;Preset $FCB2 (XITVBL)
|
||||
VDSLST = $0206 ;Display List
|
||||
;Preset $FEA1 (OSDLI)
|
||||
VKYBDI = $0208 ;Keyboard immediate
|
||||
;Preset $FD02 (SYSKBD)
|
||||
VKYBDF = $020A ;Deferred Keyboard
|
||||
;Preset $FCB2 (XITVBL)
|
||||
VTRIGR = $020C ;Soft Trigger
|
||||
VBRKOP = $020E ;BRK Opcode
|
||||
VSERIN = $0210 ;Serial in Ready
|
||||
VSEROR = $0212 ;Serial Out Ready
|
||||
VSEROC = $0214 ;Serial Output complete
|
||||
VTIMR1 = $0216 ;Pokey Timer 1
|
||||
VTIMR2 = $0218 ;Pokey Timer 2
|
||||
VTIMR4 = $021A ;Pokey Timer 4
|
||||
VIMIRQ = $0200 ; Immediate IRQ
|
||||
; Preset $FC03 (SYSIRQ)
|
||||
VVBLKI = $0202 ; Vblank immediate
|
||||
; Preset $FCB8 (SYSVBL)
|
||||
VVBLKD = $0204 ; Vblank deferred
|
||||
; Preset $FCB2 (XITVBL)
|
||||
VDSLST = $0206 ; Display List
|
||||
; Preset $FEA1 (OSDLI)
|
||||
VKYBDI = $0208 ; Keyboard immediate
|
||||
; Preset $FD02 (SYSKBD)
|
||||
VKYBDF = $020A ; Deferred Keyboard
|
||||
; Preset $FCB2 (XITVBL)
|
||||
VTRIGR = $020C ; Soft Trigger
|
||||
VBRKOP = $020E ; BRK Opcode
|
||||
VSERIN = $0210 ; Serial in Ready
|
||||
VSEROR = $0212 ; Serial Out Ready
|
||||
VSEROC = $0214 ; Serial Output complete
|
||||
VTIMR1 = $0216 ; Pokey Timer 1
|
||||
VTIMR2 = $0218 ; Pokey Timer 2
|
||||
VTIMR4 = $021A ; Pokey Timer 4
|
||||
|
||||
|
||||
|
||||
@ -84,21 +84,21 @@ VTIMR4 = $021A ;Pokey Timer 4
|
||||
; CTIA/GTIA Address Equates
|
||||
;-------------------------------------------------------------------------
|
||||
|
||||
GTIA = $C000 ;CTIA/GTIA area
|
||||
GTIA = $C000 ; CTIA/GTIA area
|
||||
.include "atari_gtia.inc"
|
||||
|
||||
;-------------------------------------------------------------------------
|
||||
; ANTIC Address Equates
|
||||
;-------------------------------------------------------------------------
|
||||
|
||||
ANTIC = $D400 ;ANTIC area
|
||||
ANTIC = $D400 ; ANTIC area
|
||||
.include "atari_antic.inc"
|
||||
|
||||
;-------------------------------------------------------------------------
|
||||
; POKEY Address Equates
|
||||
;-------------------------------------------------------------------------
|
||||
|
||||
POKEY = $E800 ;POKEY area
|
||||
POKEY = $E800 ; POKEY area
|
||||
.include "atari_pokey.inc"
|
||||
|
||||
|
||||
@ -106,11 +106,10 @@ POKEY = $E800 ;POKEY area
|
||||
; Cartridge Parameters
|
||||
;-------------------------------------------------------------------------
|
||||
|
||||
CARTNM = $BFE8 ;Cartridge Name Area
|
||||
COPYD = $BFFC ;Copyright Decade in Cart
|
||||
COPYR = $BFFD ;Copyright Year in Cart
|
||||
CARTNM = $BFE8 ; Cartridge Name Area
|
||||
COPYD = $BFFC ; Copyright Decade in Cart
|
||||
COPYR = $BFFD ; Copyright Year in Cart
|
||||
; $FF=Diagnostic Cart
|
||||
GOCART = $BFFE ;Cartridge Start Vector
|
||||
GOCART = $BFFE ; Cartridge Start Vector
|
||||
|
||||
|
||||
CHRORG = $F800 ;Character Generator Base
|
||||
CHRORG = $F800 ; Character Generator Base
|
||||
|
@ -38,6 +38,10 @@ INIT_STATUS := $A04 ; Flags: Reset/Restore initiation status
|
||||
FKEY_LEN := $1000 ; Function key lengths
|
||||
FKEY_TEXT := $100A ; Function key texts
|
||||
|
||||
KBDREPEAT := $28a
|
||||
KBDREPEATRATE := $28b
|
||||
KBDREPEATDELAY := $28c
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Kernal routines
|
||||
|
||||
|
@ -33,6 +33,9 @@ CHARCOLOR := $286
|
||||
CURS_COLOR := $287 ; Color under the cursor
|
||||
PALFLAG := $2A6 ; $01 = PAL, $00 = NTSC
|
||||
|
||||
KBDREPEAT := $28a
|
||||
KBDREPEATRATE := $28b
|
||||
KBDREPEATDELAY := $28c
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Kernal routines
|
||||
|
@ -10,10 +10,10 @@ CURSOR_X = $3C
|
||||
CURSOR_Y = $3D
|
||||
|
||||
;** VDP
|
||||
VDP_CONTROL_W = $3001
|
||||
VDP_DATA_W = $3000
|
||||
VDP_STATUS_R = $2001
|
||||
VDP_DATA_R = $2000
|
||||
VDP_STATUS_R = $2001
|
||||
VDP_DATA_W = $3000
|
||||
VDP_CONTROL_W = $3001
|
||||
|
||||
;** PIA
|
||||
PIA0_DATA = $1000
|
||||
@ -36,7 +36,26 @@ ZP_JOY1_DIR = $13
|
||||
ZP_JOY0_BUTTONS = $16
|
||||
ZP_JOY1_BUTTONS = $17
|
||||
|
||||
;** Joystick direction values (ZP_JOY0_DIR/ZP_JOY1_DIR)
|
||||
JOY_N = $49
|
||||
JOY_NNE = $48
|
||||
JOY_NE = $47
|
||||
JOY_ENE = $46
|
||||
JOY_E = $45
|
||||
JOY_ESE = $44
|
||||
JOY_SE = $43
|
||||
JOY_SSE = $42
|
||||
JOY_S = $41
|
||||
JOY_SSW = $40
|
||||
JOY_SW = $4F
|
||||
JOY_WSW = $4E
|
||||
JOY_W = $4D
|
||||
JOY_WNW = $4C
|
||||
JOY_NW = $4B
|
||||
JOY_NNW = $4A
|
||||
|
||||
;** BIOS
|
||||
BIOS_IRQ1_ADDR = $FF3F
|
||||
BIOS_IRQ2_ADDR = $FF52
|
||||
BIOS_NMI_RESET_ADDR = $F808
|
||||
BIOS_WRITE_VDP_REG = $FE1F
|
||||
|
@ -43,7 +43,6 @@
|
||||
ID .byte 3 ; $6A, $6F, $79 ("joy")
|
||||
VERSION .byte 1 ; Interface version
|
||||
LIBREF .addr ; Library reference
|
||||
MASKS .byte 8 ; Joystick state mask array
|
||||
JUMPTAB .struct
|
||||
INSTALL .addr ; INSTALL routine
|
||||
UNINSTALL .addr ; UNINSTALL routine
|
||||
|
1018
asminc/opcodes.inc
1018
asminc/opcodes.inc
File diff suppressed because it is too large
Load Diff
@ -26,11 +26,22 @@ SCR_LINELEN := $D5 ; Screen line length
|
||||
CURS_Y := $D8 ; Cursor row
|
||||
FNADR := $DA ; Pointer to file name
|
||||
|
||||
; 80-Column CBMs
|
||||
KBDREPEAT80 := $E4
|
||||
KBDRPTRATE80 := $E5
|
||||
KBDRPTDELAY80 := $E6
|
||||
|
||||
BASIC_BUF := $200 ; Location of command-line
|
||||
BASIC_BUF_LEN = 81 ; Maximum length of command-line
|
||||
|
||||
KEY_BUF := $26F ; Keyboard buffer
|
||||
|
||||
; 40-Column PETs/CBMs
|
||||
KBDRPTDELAY40 := $3E9
|
||||
KBDRPTRATE40 := $3EA
|
||||
KBDREPEAT40 := $3EE
|
||||
KBDREPEAT40B := $3F8
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; PET ROM type detection
|
||||
|
||||
@ -55,5 +66,3 @@ VIA_PRB := $E840
|
||||
VIA_PRA := $E841
|
||||
VIA_DDRB := $E842
|
||||
VIA_DDRA := $E843
|
||||
|
||||
|
||||
|
@ -33,6 +33,10 @@ FKEY_COUNT := $55D ; Characters for function key
|
||||
FKEY_SPACE := $55F ; Function key definitions
|
||||
FKEY_ORIG := $F3D2 ; Original definitions
|
||||
|
||||
KBDREPEAT := $540
|
||||
KBDREPEATRATE := $541
|
||||
KBDREPEATDELAY := $542
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Kernal routines
|
||||
|
||||
|
534
asminc/smc.inc
534
asminc/smc.inc
@ -1,267 +1,267 @@
|
||||
; smc.mac
|
||||
; ca65 Macro-Pack for Self Modifying Code (SMC)
|
||||
;
|
||||
; (c) Christian Krüger, latest change: 17-Jul-2016
|
||||
;
|
||||
; This software is provided 'as-is', without any expressed or implied
|
||||
; warranty. In no event will the authors be held liable for any damages
|
||||
; arising from the use of this software.
|
||||
;
|
||||
; Permission is granted to anyone to use this software for any purpose,
|
||||
; including commercial applications, and to alter it and redistribute it
|
||||
; freely, subject to the following restrictions:
|
||||
;
|
||||
; 1. The origin of this software must not be misrepresented; you must not
|
||||
; claim that you wrote the original software. If you use this software
|
||||
; in a product, an acknowledgment in the product documentation would be
|
||||
; appreciated but is not required.
|
||||
; 2. Altered source versions must be plainly marked as such, and must not
|
||||
; be misrepresented as being the original software.
|
||||
; 3. This notice may not be removed or altered from any source
|
||||
; distribution.
|
||||
;
|
||||
|
||||
.define _SMCDesignator .mid(0, .tcount(label) - 1, label) .ident(.concat(.string(.right(1, label)), "_SMC"))
|
||||
.define _SMCAlias .mid(0, .tcount(alias) - 1, alias) .ident(.concat(.string(.right(1, alias)), "_SMC"))
|
||||
.define SMC_AbsAdr $FADE
|
||||
.define SMC_ZpAdr $00
|
||||
.define SMC_Opcode nop
|
||||
.define SMC_Value $42
|
||||
|
||||
.macro SMC_OperateOnValue opcode, label
|
||||
opcode _SMCDesignator+1
|
||||
.endmacro
|
||||
|
||||
.macro SMC_OperateOnLowByte opcode, label
|
||||
SMC_OperateOnValue opcode, label
|
||||
.endmacro
|
||||
|
||||
.macro SMC_OperateOnHighByte opcode, label
|
||||
opcode _SMCDesignator + 2
|
||||
.endmacro
|
||||
|
||||
.macro SMC_Import alias
|
||||
.import _SMCAlias
|
||||
.endmacro
|
||||
|
||||
.macro SMC_Export alias, label
|
||||
.export _SMCAlias := _SMCDesignator
|
||||
.endmacro
|
||||
|
||||
.macro SMC label, statement
|
||||
_SMCDesignator: statement
|
||||
.endmacro
|
||||
|
||||
.macro SMC_TransferOpcode label, opcode, register
|
||||
.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )
|
||||
lda #opcode
|
||||
sta _SMCDesignator
|
||||
.elseif .match ({register}, x)
|
||||
ldx #opcode
|
||||
stx _SMCDesignator
|
||||
.elseif .match ({register}, y)
|
||||
ldy #opcode
|
||||
sty _SMCDesignator
|
||||
.else
|
||||
.error "Invalid usage of macro 'SMC_TransferOpcode'"
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
.macro SMC_LoadOpcode label, register
|
||||
.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
|
||||
lda _SMCDesignator
|
||||
.elseif .match ({register}, x)
|
||||
ldx _SMCDesignator
|
||||
.elseif .match ({register}, y)
|
||||
ldy _SMCDesignator
|
||||
.else
|
||||
.error "Invalid usage of macro 'SMC_LoadOpcode'"
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
.macro SMC_StoreOpcode label, register
|
||||
.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
|
||||
sta _SMCDesignator
|
||||
.elseif .match ({register}, x)
|
||||
stx _SMCDesignator
|
||||
.elseif .match ({register}, y)
|
||||
sty _SMCDesignator
|
||||
.else
|
||||
.error "Invalid usage of macro 'SMC_StoreOpcode'"
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
.macro SMC_ChangeBranch label, destination, register
|
||||
.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )
|
||||
lda #(<(destination - _SMCDesignator -2))
|
||||
sta _SMCDesignator+1
|
||||
.elseif .match ({register}, x)
|
||||
ldx #(<(destination - _SMCDesignator - 2))
|
||||
stx _SMCDesignator+1
|
||||
.elseif .match ({register}, y)
|
||||
ldy #(<(destination - _SMCDesignator - 2))
|
||||
sty _SMCDesignator+1
|
||||
.else
|
||||
.error "Invalid usage of macro 'SMC_ChangeBranch'"
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
.macro SMC_TransferValue label, value, register
|
||||
.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )
|
||||
lda value
|
||||
sta _SMCDesignator+1
|
||||
.elseif .match ({register}, x)
|
||||
ldx value
|
||||
stx _SMCDesignator+1
|
||||
.elseif .match ({register}, y)
|
||||
ldy value
|
||||
sty _SMCDesignator+1
|
||||
.else
|
||||
.error "Invalid usage of macro 'SMC_TransferValue'"
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
.macro SMC_LoadValue label, register
|
||||
.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
|
||||
lda _SMCDesignator+1
|
||||
.elseif .match ({register}, x)
|
||||
ldx _SMCDesignator+1
|
||||
.elseif .match ({register}, y)
|
||||
ldy _SMCDesignator+1
|
||||
.else
|
||||
.error "Invalid usage of macro 'SMC_LoadValue'"
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
.macro SMC_StoreValue label, register
|
||||
.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
|
||||
sta _SMCDesignator+1
|
||||
.elseif .match ({register}, x)
|
||||
stx _SMCDesignator+1
|
||||
.elseif .match ({register}, y)
|
||||
sty _SMCDesignator+1
|
||||
.else
|
||||
.error "Invalid usage of macro 'SMC_StoreValue'"
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
|
||||
.macro SMC_TransferLowByte label, value, register
|
||||
SMC_TransferValue label, value, register
|
||||
.endmacro
|
||||
|
||||
.macro SMC_LoadLowByte label, register
|
||||
SMC_LoadValue label, register
|
||||
.endmacro
|
||||
|
||||
.macro SMC_StoreLowByte label, register
|
||||
SMC_StoreValue label, register
|
||||
.endmacro
|
||||
|
||||
.macro SMC_TransferHighByte label, value, register
|
||||
.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )
|
||||
lda value
|
||||
sta _SMCDesignator+2
|
||||
.elseif .match ({register}, x)
|
||||
ldx value
|
||||
stx _SMCDesignator+2
|
||||
.elseif .match ({register}, y)
|
||||
ldy value
|
||||
sty _SMCDesignator+2
|
||||
.else
|
||||
.error "Invalid usage of macro 'SMC_TransferHighByte'"
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
.macro SMC_LoadHighByte label, register
|
||||
.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
|
||||
lda _SMCDesignator+2
|
||||
.elseif .match ({register}, x)
|
||||
ldx _SMCDesignator+2
|
||||
.elseif .match ({register}, y)
|
||||
ldy _SMCDesignator+2
|
||||
.else
|
||||
.error "Invalid usage of macro 'SMC_LoadHighByte'"
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
.macro SMC_StoreHighByte label, register
|
||||
.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
|
||||
sta _SMCDesignator+2
|
||||
.elseif .match ({register}, x)
|
||||
stx _SMCDesignator+2
|
||||
.elseif .match ({register}, y)
|
||||
sty _SMCDesignator+2
|
||||
.else
|
||||
.error "Invalid usage of macro 'SMC_StoreHighByte'"
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
.macro SMC_TransferAddressSingle label, address, register
|
||||
.if .paramcount = 2 .or .match ((register), a) .or .match ({register}, )
|
||||
.if (.match (.left (1, {address}), #))
|
||||
; immediate mode
|
||||
lda #<(.right (.tcount ({address})-1, {address}))
|
||||
sta _SMCDesignator+1
|
||||
lda #>(.right (.tcount ({address})-1, {address}))
|
||||
sta _SMCDesignator+2
|
||||
.else
|
||||
; assume absolute or zero page
|
||||
lda address
|
||||
sta _SMCDesignator+1
|
||||
lda 1+(address)
|
||||
sta _SMCDesignator+2
|
||||
.endif
|
||||
.elseif .match ((register), x)
|
||||
.if (.match (.left (1, {address}), #))
|
||||
; immediate mode
|
||||
ldx #<(.right (.tcount ({address})-1, {address}))
|
||||
stx _SMCDesignator+1
|
||||
ldx #>(.right (.tcount ({address})-1, {address}))
|
||||
stx _SMCDesignator+2
|
||||
.else
|
||||
; assume absolute or zero page
|
||||
ldx address
|
||||
stx _SMCDesignator+1
|
||||
ldx 1+(address)
|
||||
stx _SMCDesignator+2
|
||||
.endif
|
||||
.elseif .match ((register), y)
|
||||
.if (.match (.left (1, {address}), #))
|
||||
; immediate mode
|
||||
ldy #<(.right (.tcount ({address})-1, {address}))
|
||||
sty _SMCDesignator+1
|
||||
ldy #>(.right (.tcount ({address})-1, {address}))
|
||||
sty _SMCDesignator+2
|
||||
.else
|
||||
; assume absolute or zero page
|
||||
ldy address
|
||||
sty _SMCDesignator+1
|
||||
ldy 1+(address)
|
||||
sty _SMCDesignator+2
|
||||
.endif
|
||||
.else
|
||||
.error "Invalid usage of macro 'SMC_TransferAddressSingle'"
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
.macro SMC_TransferAddress label, address
|
||||
.if (.match (.left (1, {address}), #))
|
||||
; immediate mode
|
||||
lda #<(.right (.tcount ({address})-1, {address}))
|
||||
sta _SMCDesignator+1
|
||||
ldx #>(.right (.tcount ({address})-1, {address}))
|
||||
stx _SMCDesignator+2
|
||||
.else
|
||||
; assume absolute or zero page
|
||||
lda {address}
|
||||
sta _SMCDesignator+1
|
||||
ldx 1+{address}
|
||||
stx _SMCDesignator)+2
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
.macro SMC_StoreAddress label
|
||||
sta _SMCDesignator+1
|
||||
stx _SMCDesignator+2
|
||||
.endmacro
|
||||
; smc.mac
|
||||
; ca65 Macro-Pack for Self Modifying Code (SMC)
|
||||
;
|
||||
; (c) Christian Krüger, latest change: 17-Jul-2016
|
||||
;
|
||||
; This software is provided 'as-is', without any expressed or implied
|
||||
; warranty. In no event will the authors be held liable for any damages
|
||||
; arising from the use of this software.
|
||||
;
|
||||
; Permission is granted to anyone to use this software for any purpose,
|
||||
; including commercial applications, and to alter it and redistribute it
|
||||
; freely, subject to the following restrictions:
|
||||
;
|
||||
; 1. The origin of this software must not be misrepresented; you must not
|
||||
; claim that you wrote the original software. If you use this software
|
||||
; in a product, an acknowledgment in the product documentation would be
|
||||
; appreciated but is not required.
|
||||
; 2. Altered source versions must be plainly marked as such, and must not
|
||||
; be misrepresented as being the original software.
|
||||
; 3. This notice may not be removed or altered from any source
|
||||
; distribution.
|
||||
;
|
||||
|
||||
.define _SMCDesignator .mid(0, .tcount(label) - 1, label) .ident(.concat(.string(.right(1, label)), "_SMC"))
|
||||
.define _SMCAlias .mid(0, .tcount(alias) - 1, alias) .ident(.concat(.string(.right(1, alias)), "_SMC"))
|
||||
.define SMC_AbsAdr $FADE
|
||||
.define SMC_ZpAdr $00
|
||||
.define SMC_Opcode nop
|
||||
.define SMC_Value $42
|
||||
|
||||
.macro SMC_OperateOnValue opcode, label
|
||||
opcode _SMCDesignator+1
|
||||
.endmacro
|
||||
|
||||
.macro SMC_OperateOnLowByte opcode, label
|
||||
SMC_OperateOnValue opcode, label
|
||||
.endmacro
|
||||
|
||||
.macro SMC_OperateOnHighByte opcode, label
|
||||
opcode _SMCDesignator + 2
|
||||
.endmacro
|
||||
|
||||
.macro SMC_Import alias
|
||||
.import _SMCAlias
|
||||
.endmacro
|
||||
|
||||
.macro SMC_Export alias, label
|
||||
.export _SMCAlias := _SMCDesignator
|
||||
.endmacro
|
||||
|
||||
.macro SMC label, statement
|
||||
_SMCDesignator: statement
|
||||
.endmacro
|
||||
|
||||
.macro SMC_TransferOpcode label, opcode, register
|
||||
.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )
|
||||
lda #opcode
|
||||
sta _SMCDesignator
|
||||
.elseif .match ({register}, x)
|
||||
ldx #opcode
|
||||
stx _SMCDesignator
|
||||
.elseif .match ({register}, y)
|
||||
ldy #opcode
|
||||
sty _SMCDesignator
|
||||
.else
|
||||
.error "Invalid usage of macro 'SMC_TransferOpcode'"
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
.macro SMC_LoadOpcode label, register
|
||||
.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
|
||||
lda _SMCDesignator
|
||||
.elseif .match ({register}, x)
|
||||
ldx _SMCDesignator
|
||||
.elseif .match ({register}, y)
|
||||
ldy _SMCDesignator
|
||||
.else
|
||||
.error "Invalid usage of macro 'SMC_LoadOpcode'"
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
.macro SMC_StoreOpcode label, register
|
||||
.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
|
||||
sta _SMCDesignator
|
||||
.elseif .match ({register}, x)
|
||||
stx _SMCDesignator
|
||||
.elseif .match ({register}, y)
|
||||
sty _SMCDesignator
|
||||
.else
|
||||
.error "Invalid usage of macro 'SMC_StoreOpcode'"
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
.macro SMC_ChangeBranch label, destination, register
|
||||
.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )
|
||||
lda #(<(destination - _SMCDesignator -2))
|
||||
sta _SMCDesignator+1
|
||||
.elseif .match ({register}, x)
|
||||
ldx #(<(destination - _SMCDesignator - 2))
|
||||
stx _SMCDesignator+1
|
||||
.elseif .match ({register}, y)
|
||||
ldy #(<(destination - _SMCDesignator - 2))
|
||||
sty _SMCDesignator+1
|
||||
.else
|
||||
.error "Invalid usage of macro 'SMC_ChangeBranch'"
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
.macro SMC_TransferValue label, value, register
|
||||
.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )
|
||||
lda value
|
||||
sta _SMCDesignator+1
|
||||
.elseif .match ({register}, x)
|
||||
ldx value
|
||||
stx _SMCDesignator+1
|
||||
.elseif .match ({register}, y)
|
||||
ldy value
|
||||
sty _SMCDesignator+1
|
||||
.else
|
||||
.error "Invalid usage of macro 'SMC_TransferValue'"
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
.macro SMC_LoadValue label, register
|
||||
.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
|
||||
lda _SMCDesignator+1
|
||||
.elseif .match ({register}, x)
|
||||
ldx _SMCDesignator+1
|
||||
.elseif .match ({register}, y)
|
||||
ldy _SMCDesignator+1
|
||||
.else
|
||||
.error "Invalid usage of macro 'SMC_LoadValue'"
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
.macro SMC_StoreValue label, register
|
||||
.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
|
||||
sta _SMCDesignator+1
|
||||
.elseif .match ({register}, x)
|
||||
stx _SMCDesignator+1
|
||||
.elseif .match ({register}, y)
|
||||
sty _SMCDesignator+1
|
||||
.else
|
||||
.error "Invalid usage of macro 'SMC_StoreValue'"
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
|
||||
.macro SMC_TransferLowByte label, value, register
|
||||
SMC_TransferValue label, value, register
|
||||
.endmacro
|
||||
|
||||
.macro SMC_LoadLowByte label, register
|
||||
SMC_LoadValue label, register
|
||||
.endmacro
|
||||
|
||||
.macro SMC_StoreLowByte label, register
|
||||
SMC_StoreValue label, register
|
||||
.endmacro
|
||||
|
||||
.macro SMC_TransferHighByte label, value, register
|
||||
.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )
|
||||
lda value
|
||||
sta _SMCDesignator+2
|
||||
.elseif .match ({register}, x)
|
||||
ldx value
|
||||
stx _SMCDesignator+2
|
||||
.elseif .match ({register}, y)
|
||||
ldy value
|
||||
sty _SMCDesignator+2
|
||||
.else
|
||||
.error "Invalid usage of macro 'SMC_TransferHighByte'"
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
.macro SMC_LoadHighByte label, register
|
||||
.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
|
||||
lda _SMCDesignator+2
|
||||
.elseif .match ({register}, x)
|
||||
ldx _SMCDesignator+2
|
||||
.elseif .match ({register}, y)
|
||||
ldy _SMCDesignator+2
|
||||
.else
|
||||
.error "Invalid usage of macro 'SMC_LoadHighByte'"
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
.macro SMC_StoreHighByte label, register
|
||||
.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
|
||||
sta _SMCDesignator+2
|
||||
.elseif .match ({register}, x)
|
||||
stx _SMCDesignator+2
|
||||
.elseif .match ({register}, y)
|
||||
sty _SMCDesignator+2
|
||||
.else
|
||||
.error "Invalid usage of macro 'SMC_StoreHighByte'"
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
.macro SMC_TransferAddressSingle label, address, register
|
||||
.if .paramcount = 2 .or .match ((register), a) .or .match ({register}, )
|
||||
.if (.match (.left (1, {address}), #))
|
||||
; immediate mode
|
||||
lda #<(.right (.tcount ({address})-1, {address}))
|
||||
sta _SMCDesignator+1
|
||||
lda #>(.right (.tcount ({address})-1, {address}))
|
||||
sta _SMCDesignator+2
|
||||
.else
|
||||
; assume absolute or zero page
|
||||
lda address
|
||||
sta _SMCDesignator+1
|
||||
lda 1+(address)
|
||||
sta _SMCDesignator+2
|
||||
.endif
|
||||
.elseif .match ((register), x)
|
||||
.if (.match (.left (1, {address}), #))
|
||||
; immediate mode
|
||||
ldx #<(.right (.tcount ({address})-1, {address}))
|
||||
stx _SMCDesignator+1
|
||||
ldx #>(.right (.tcount ({address})-1, {address}))
|
||||
stx _SMCDesignator+2
|
||||
.else
|
||||
; assume absolute or zero page
|
||||
ldx address
|
||||
stx _SMCDesignator+1
|
||||
ldx 1+(address)
|
||||
stx _SMCDesignator+2
|
||||
.endif
|
||||
.elseif .match ((register), y)
|
||||
.if (.match (.left (1, {address}), #))
|
||||
; immediate mode
|
||||
ldy #<(.right (.tcount ({address})-1, {address}))
|
||||
sty _SMCDesignator+1
|
||||
ldy #>(.right (.tcount ({address})-1, {address}))
|
||||
sty _SMCDesignator+2
|
||||
.else
|
||||
; assume absolute or zero page
|
||||
ldy address
|
||||
sty _SMCDesignator+1
|
||||
ldy 1+(address)
|
||||
sty _SMCDesignator+2
|
||||
.endif
|
||||
.else
|
||||
.error "Invalid usage of macro 'SMC_TransferAddressSingle'"
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
.macro SMC_TransferAddress label, address
|
||||
.if (.match (.left (1, {address}), #))
|
||||
; immediate mode
|
||||
lda #<(.right (.tcount ({address})-1, {address}))
|
||||
sta _SMCDesignator+1
|
||||
ldx #>(.right (.tcount ({address})-1, {address}))
|
||||
stx _SMCDesignator+2
|
||||
.else
|
||||
; assume absolute or zero page
|
||||
lda {address}
|
||||
sta _SMCDesignator+1
|
||||
ldx 1+{address}
|
||||
stx _SMCDesignator)+2
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
.macro SMC_StoreAddress label
|
||||
sta _SMCDesignator+1
|
||||
stx _SMCDesignator+2
|
||||
.endmacro
|
||||
|
@ -31,6 +31,9 @@ BASIC_BUF_LEN = 89 ; Maximum length of command-line
|
||||
CHARCOLOR := $286
|
||||
CURS_COLOR := $287 ; Color under the cursor
|
||||
|
||||
KBDREPEAT := $28a
|
||||
KBDREPEATRATE := $28b
|
||||
KBDREPEATDELAY := $28c
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Screen size
|
||||
|
@ -4,7 +4,7 @@ SYMBOLS {
|
||||
MEMORY {
|
||||
ZP: file = "", define = yes, start = $0020, size = $00E0;
|
||||
RAM: file = "", define = yes, start = $01FA, size = $0206;
|
||||
ROM: file = %O, define = yes, start = $B000, size = $1000;
|
||||
ROM: file = %O, define = yes, start = $B000, size = $1000, fill = yes, fillval = $FF;
|
||||
}
|
||||
SEGMENTS {
|
||||
ZEROPAGE: load = ZP, type = zp;
|
||||
|
@ -3,7 +3,7 @@ SYMBOLS {
|
||||
__STACKSIZE__: type = weak, value = $0800; # 2k stack
|
||||
}
|
||||
MEMORY {
|
||||
ZP: file = "", start = $0000, size = $001A;
|
||||
ZP: file = "", start = $0000, size = $001B;
|
||||
HEADER: file = %O, start = $0000, size = $0001;
|
||||
MAIN: file = %O, define = yes, start = $0200, size = $FDF0 - __STACKSIZE__;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ SYMBOLS {
|
||||
__STACKSIZE__: type = weak, value = $0800; # 2k stack
|
||||
}
|
||||
MEMORY {
|
||||
ZP: file = "", start = $0000, size = $001A;
|
||||
ZP: file = "", start = $0000, size = $001B;
|
||||
HEADER: file = %O, start = $0000, size = $0001;
|
||||
MAIN: file = %O, define = yes, start = $0200, size = $FDF0 - __STACKSIZE__;
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ endif
|
||||
|
||||
.SUFFIXES:
|
||||
|
||||
htmldir = $(prefix)/share/doc/cc65$(DESTPACKAGE_SUFFIX)/html
|
||||
infodir = $(prefix)/share/info
|
||||
htmldir = $(PREFIX)/share/doc/cc65$(DESTPACKAGE_SUFFIX)/html
|
||||
infodir = $(PREFIX)/share/info
|
||||
|
||||
ifdef CMD_EXE
|
||||
|
||||
@ -46,7 +46,7 @@ clean:
|
||||
$(RM) -r ../html ../info
|
||||
|
||||
install:
|
||||
$(if $(prefix),,$(error variable `prefix' must be set))
|
||||
$(if $(PREFIX),,$(error variable `PREFIX' must be set))
|
||||
ifeq ($(wildcard ../html),../html)
|
||||
$(INSTALL) -d $(DESTDIR)$(htmldir)
|
||||
$(INSTALL) -m0644 ../html/*.* $(DESTDIR)$(htmldir)
|
||||
|
105
doc/apple2.sgml
105
doc/apple2.sgml
@ -435,7 +435,7 @@ BASIC.SYSTEM) there are some limitations for DOS 3.3:
|
||||
<tag/Interrupts/
|
||||
There's no <tt/interruptor/ support. Any attempt to use it yields the message
|
||||
'FAILED TO ALLOC INTERRUPT' on program startup. This implicitly means that
|
||||
<tt/a2.stdmou.mou/ and <tt/a2.ssc.ser/ are not functional as they depend on
|
||||
joystick, mouse and RS232 device drivers are not functional as they depend on
|
||||
interrupts.
|
||||
|
||||
</descrip><p>
|
||||
@ -511,6 +511,109 @@ url="ca65.html" name="assembler manual">.
|
||||
</descrip><p>
|
||||
|
||||
|
||||
<sect1>Specifying file types for fopen<p>
|
||||
|
||||
<descrip>
|
||||
|
||||
<tag>Explanation of File Types</tag>
|
||||
|
||||
ProDOS associates a file type and an auxiliary type with each file.
|
||||
These type specifications are separate from the file's name, unlike
|
||||
Windows which uses the file name's suffix (a.k.a.
|
||||
extension) to specify the file type. For example, <tt/.exe/,
|
||||
<tt/.doc/, or <tt/.bat/.
|
||||
The ProDOS low-level
|
||||
Machine-Language Interface (MLI) functions for creating and opening
|
||||
files require these types to be specified. And if they don't match
|
||||
with the file being opened, the operation may fail.
|
||||
|
||||
In contrast, the ISO C function <tt/fopen()/ and the POSIX function
|
||||
<tt/open()/ have no parameter to specify either a file type or an
|
||||
auxiliary type. Therefore, some additional mechanism for specifying
|
||||
the file types is needed.
|
||||
|
||||
<tag>Specifying the File Type and Auxiliary Type</tag>
|
||||
|
||||
There are two global variables provided that allow the file type
|
||||
and auxiliary type to be specified before a call to <tt/fopen()/
|
||||
or <tt/open()/. They are defined in <tt/apple2_filetype.h/:
|
||||
|
||||
<tscreen>
|
||||
<verb>
|
||||
extern unsigned char _filetype; /* Default: PRODOS_T_BIN */
|
||||
extern unsigned int _auxtype; /* Default: 0 */
|
||||
</verb>
|
||||
</tscreen>
|
||||
|
||||
The header file <tt/apple2_filetype.h/ also defines many values
|
||||
that can be used to set these variables. It is included in
|
||||
<tt/apple2.h/, which is in turn included in <tt/apple2enh.h/.
|
||||
So it isn't necessary to include it directly. Just
|
||||
include one of <tt/apple2.h/ or <tt/apple2enh.h/.
|
||||
|
||||
<tag>Example</tag>
|
||||
|
||||
A text file cannot be created with just the
|
||||
standard C functions because they default to the binary type
|
||||
<tt/PRODOS_T_BIN/. The <tt/_filetype/ variable must be set to
|
||||
<tt/PRODOS_T_TXT/ to create a text file.
|
||||
|
||||
For a text file,
|
||||
<tt/_auxtype/ specifies the record length. A zero record
|
||||
length text file is referred to as a sequential text file.
|
||||
This is equivalent to text files on
|
||||
other operating systems, except that the line terminator is a
|
||||
carriage return instead of a line-feed (Linux/BSD/MacOS) or
|
||||
carriage return, line-feed pair (Windows).
|
||||
|
||||
The "sequential" text file terminology is in contrast to a
|
||||
"random-access" text file which would
|
||||
have a fixed-length, non-zero record length, so that the
|
||||
file position of any individual record can be calculated.
|
||||
|
||||
For this example, the
|
||||
<tt/_auxtype/ does not need to be set because it defaults to
|
||||
the desired value, which is zero. To be more explicit,
|
||||
<tt/_auxtype/ can also be set to <tt/PRODOS_AUX_T_TXT_SEQ/
|
||||
which is defined as zero.
|
||||
|
||||
<tscreen>
|
||||
<verb>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <apple2.h>
|
||||
|
||||
void main(void)
|
||||
{
|
||||
FILE *out;
|
||||
char *name = "MY.FAVS";
|
||||
|
||||
/*-----------------------------*/
|
||||
|
||||
_filetype = PRODOS_T_TXT;
|
||||
_auxtype = PRODOS_AUX_T_TXT_SEQ;
|
||||
|
||||
/*-----------------------------*/
|
||||
|
||||
if ((out = fopen(name, "w")) != NULL) {
|
||||
fputs("Jorah Mormont\r", out);
|
||||
fputs("Brienne of Tarth\r", out);
|
||||
fputs("Daenerys Targaryen\r", out);
|
||||
fputs("Sandor Clegane\r", out);
|
||||
if (fclose(out) == EOF) {
|
||||
fprintf(stderr, "fclose failed for %s: %s", name, strerror(errno));
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "fopen failed for %s: %s", name, strerror(errno));
|
||||
}
|
||||
}
|
||||
</verb>
|
||||
</tscreen>
|
||||
|
||||
</descrip><p>
|
||||
|
||||
|
||||
<sect>License<p>
|
||||
|
||||
|
@ -436,7 +436,7 @@ BASIC.SYSTEM) there are some limitations for DOS 3.3:
|
||||
<tag/Interrupts/
|
||||
There's no <tt/interruptor/ support. Any attempt to use it yields the message
|
||||
'Failed to alloc interrupt' on program startup. This implicitly means that
|
||||
<tt/a2e.stdmou.mou/ and <tt/a2e.ssc.ser/ are not functional as they depend on
|
||||
joystick, mouse and RS232 device drivers are not functional as they depend on
|
||||
interrupts.
|
||||
|
||||
</descrip><p>
|
||||
@ -517,6 +517,109 @@ url="ca65.html" name="assembler manual">.
|
||||
</descrip><p>
|
||||
|
||||
|
||||
<sect1>Specifying file types for fopen<p>
|
||||
|
||||
<descrip>
|
||||
|
||||
<tag>Explanation of File Types</tag>
|
||||
|
||||
ProDOS associates a file type and an auxiliary type with each file.
|
||||
These type specifications are separate from the file's name, unlike
|
||||
Windows which uses the file name's suffix (a.k.a.
|
||||
extension) to specify the file type. For example, <tt/.exe/,
|
||||
<tt/.doc/, or <tt/.bat/.
|
||||
The ProDOS low-level
|
||||
Machine-Language Interface (MLI) functions for creating and opening
|
||||
files require these types to be specified. And if they don't match
|
||||
with the file being opened, the operation may fail.
|
||||
|
||||
In contrast, the ISO C function <tt/fopen()/ and the POSIX function
|
||||
<tt/open()/ have no parameter to specify either a file type or an
|
||||
auxiliary type. Therefore, some additional mechanism for specifying
|
||||
the file types is needed.
|
||||
|
||||
<tag>Specifying the File Type and Auxiliary Type</tag>
|
||||
|
||||
There are two global variables provided that allow the file type
|
||||
and auxiliary type to be specified before a call to <tt/fopen()/
|
||||
or <tt/open()/. They are defined in <tt/apple2_filetype.h/:
|
||||
|
||||
<tscreen>
|
||||
<verb>
|
||||
extern unsigned char _filetype; /* Default: PRODOS_T_BIN */
|
||||
extern unsigned int _auxtype; /* Default: 0 */
|
||||
</verb>
|
||||
</tscreen>
|
||||
|
||||
The header file <tt/apple2_filetype.h/ also defines many values
|
||||
that can be used to set these variables. It is included in
|
||||
<tt/apple2.h/, which is in turn included in <tt/apple2enh.h/.
|
||||
So it isn't necessary to include it directly. Just
|
||||
include one of <tt/apple2.h/ or <tt/apple2enh.h/.
|
||||
|
||||
<tag>Example</tag>
|
||||
|
||||
A text file cannot be created with just the
|
||||
standard C functions because they default to the binary type
|
||||
<tt/PRODOS_T_BIN/. The <tt/_filetype/ variable must be set to
|
||||
<tt/PRODOS_T_TXT/ to create a text file.
|
||||
|
||||
For a text file,
|
||||
<tt/_auxtype/ specifies the record length. A zero record
|
||||
length text file is referred to as a sequential text file.
|
||||
This is equivalent to text files on
|
||||
other operating systems, except that the line terminator is a
|
||||
carriage return instead of a line-feed (Linux/BSD/MacOS) or
|
||||
carriage return, line-feed pair (Windows).
|
||||
|
||||
The "sequential" text file terminology is in contrast to a
|
||||
"random-access" text file which would
|
||||
have a fixed-length, non-zero record length, so that the
|
||||
file position of any individual record can be calculated.
|
||||
|
||||
For this example, the
|
||||
<tt/_auxtype/ does not need to be set because it defaults to
|
||||
the desired value, which is zero. To be more explicit,
|
||||
<tt/_auxtype/ can also be set to <tt/PRODOS_AUX_T_TXT_SEQ/
|
||||
which is defined as zero.
|
||||
|
||||
<tscreen>
|
||||
<verb>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <apple2.h>
|
||||
|
||||
void main(void)
|
||||
{
|
||||
FILE *out;
|
||||
char *name = "MY.FAVS";
|
||||
|
||||
/*-----------------------------*/
|
||||
|
||||
_filetype = PRODOS_T_TXT;
|
||||
_auxtype = PRODOS_AUX_T_TXT_SEQ;
|
||||
|
||||
/*-----------------------------*/
|
||||
|
||||
if ((out = fopen(name, "w")) != NULL) {
|
||||
fputs("Jorah Mormont\r", out);
|
||||
fputs("Brienne of Tarth\r", out);
|
||||
fputs("Daenerys Targaryen\r", out);
|
||||
fputs("Sandor Clegane\r", out);
|
||||
if (fclose(out) == EOF) {
|
||||
fprintf(stderr, "fclose failed for %s: %s", name, strerror(errno));
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "fopen failed for %s: %s", name, strerror(errno));
|
||||
}
|
||||
}
|
||||
</verb>
|
||||
</tscreen>
|
||||
|
||||
</descrip><p>
|
||||
|
||||
|
||||
<sect>License<p>
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
<title>ar65 Users Guide
|
||||
<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">
|
||||
<date>19.07.2000
|
||||
<date>2017-05-28
|
||||
|
||||
<abstract>
|
||||
ar65 is an archiver for object files generated by ca65. It allows to create
|
||||
@ -32,16 +32,17 @@ for the cc65 compiler. ar65 is part of this suite.
|
||||
The archiver is called as follows:
|
||||
|
||||
<tscreen><verb>
|
||||
Usage: ar65 <operation> lib file|module ...
|
||||
Operation is one of:
|
||||
a Add modules
|
||||
d Delete modules
|
||||
l List library contents
|
||||
x Extract modules
|
||||
V Print the archiver version
|
||||
Usage: ar65 <operation ...> lib file|module ...
|
||||
Operations are some of:
|
||||
r Add modules
|
||||
d Delete modules
|
||||
t List library table
|
||||
v Increase verbosity (put before other operation)
|
||||
x Extract modules
|
||||
V Print the archiver version
|
||||
</verb></tscreen>
|
||||
|
||||
You may add modules to a library using the `a' command. If the library
|
||||
You may add modules to a library using the `r' command (`a' is deprecated). If the library
|
||||
does not exist, it is created (and a warning message is printed which you
|
||||
may ignore if creation of the library was your intention). You may
|
||||
specify any number of modules on the command line following the library.
|
||||
@ -53,7 +54,7 @@ has a newer timestamp than the one to add.
|
||||
Here's an example:
|
||||
|
||||
<tscreen><verb>
|
||||
ar65 a mysubs.lib sub1.o sub2.o
|
||||
ar65 r mysubs.lib sub1.o sub2.o
|
||||
</verb></tscreen>
|
||||
|
||||
This will add two modules to the library `mysubs.lib' creating the
|
||||
@ -63,10 +64,10 @@ sub2.o, they are replaced by the new ones.
|
||||
Modules names in the library are stored without the path, so, using
|
||||
|
||||
<tscreen><verb>
|
||||
ar65 a mysubs.lib ofiles/sub1.o ofiles/sub2.o
|
||||
ar65 v v r mysubs.lib ofiles/sub1.o ofiles/sub2.o
|
||||
</verb></tscreen>
|
||||
|
||||
will add two modules named `sub1.o' and `sub2.o' to the library.
|
||||
will verbose add two modules named `sub1.o' and `sub2.o' to the library.
|
||||
|
||||
Deleting modules from a library is done with the `d' command. You may not
|
||||
give a path when naming the modules.
|
||||
@ -81,13 +82,13 @@ This will delete the module named `sub1.o' from the library, printing an
|
||||
error if the library does not contain that module.
|
||||
|
||||
|
||||
The `l' command prints a list of all modules in the library. Any module
|
||||
names on the command line are ignored.
|
||||
The `t' command prints a table of all modules in the library (`l' is deprecated).
|
||||
Any module names on the command line are ignored.
|
||||
|
||||
Example:
|
||||
|
||||
<tscreen><verb>
|
||||
ar65 l mysubs.lib
|
||||
ar65 tv mysubs.lib
|
||||
</verb></tscreen>
|
||||
|
||||
|
||||
|
@ -1636,7 +1636,7 @@ either a string or an expression.
|
||||
|
||||
<tscreen><verb>
|
||||
; Reserve space for the larger of two data blocks
|
||||
savearea: .max (.sizeof (foo), .sizeof (bar))
|
||||
savearea: .res .max (.sizeof (foo), .sizeof (bar))
|
||||
</verb></tscreen>
|
||||
|
||||
See: <tt><ref id=".MIN" name=".MIN"></tt>
|
||||
@ -1695,8 +1695,8 @@ either a string or an expression.
|
||||
Example:
|
||||
|
||||
<tscreen><verb>
|
||||
; Reserve space for some data, but 256 bytes minimum
|
||||
savearea: .min (.sizeof (foo), 256)
|
||||
; Reserve space for some data, but 256 bytes maximum
|
||||
savearea: .res .min (.sizeof (foo), 256)
|
||||
</verb></tscreen>
|
||||
|
||||
See: <tt><ref id=".MAX" name=".MAX"></tt>
|
||||
@ -4305,6 +4305,13 @@ different:
|
||||
some things may be done with both macro types, each type has special
|
||||
usages. The types complement each other.
|
||||
|
||||
<item> Parentheses work differently from C macros.
|
||||
The common practice of wrapping C macros in parentheses may cause
|
||||
unintended problems here, such as accidentally implying an
|
||||
indirect addressing mode. While the definition of a macro requires
|
||||
parentheses around its argument list, when invoked they should not be
|
||||
included.
|
||||
|
||||
</itemize>
|
||||
|
||||
Let's look at a few examples to make the advantages and disadvantages
|
||||
@ -4337,18 +4344,42 @@ Macros with parameters may also be useful:
|
||||
DEBUG "Assembling include file #3"
|
||||
</verb></tscreen>
|
||||
|
||||
Note that, while formal parameters have to be placed in braces, this is
|
||||
not true for the actual parameters. Beware: Since the assembler cannot
|
||||
detect the end of one parameter, only the first token is used. If you
|
||||
don't like that, use classic macros instead:
|
||||
Note that, while formal parameters have to be placed in parentheses,
|
||||
the actual argument used when invoking the macro should not be.
|
||||
The invoked arguments are separated by commas only, if parentheses are
|
||||
used by accident they will become part of the replaced token.
|
||||
|
||||
If you wish to have an expression follow the macro invocation, the
|
||||
last parameter can be enclosed in curly braces {} to indicate the end of that
|
||||
argument.
|
||||
|
||||
Examples:
|
||||
|
||||
<tscreen><verb>
|
||||
.macro DEBUG message
|
||||
.out message
|
||||
.endmacro
|
||||
.define COMBINE(ta,tb,tc) ta+tb*10+tc*100
|
||||
|
||||
.word COMBINE 5,6,7 ; 5+6*10+7*100 = 765
|
||||
.word COMBINE(5,6,7) ; (5+6*10+7)*100 = 7200 ; incorrect use of parentheses
|
||||
.word COMBINE 5,6,7+1 ; 5+6*10+7+1*100 = 172
|
||||
.word COMBINE 5,6,{7}+1 ; 5+6*10+7*100+1 = 766 ; {} encloses the argument
|
||||
.word COMBINE 5,6-2,7 ; 5+6-2*10+7*100 = 691
|
||||
.word COMBINE 5,(6-2),7 ; 5+(6-2)*10+7*100 = 745
|
||||
.word COMBINE 5,6,7+COMBINE 0,1,2 ; 5+6*10+7+0+1*10+2*100*100 = 20082
|
||||
.word COMBINE 5,6,{7}+COMBINE 0,1,2 ; 5+6*10+7*100+0+1*10+2*100 = 975
|
||||
</verb></tscreen>
|
||||
|
||||
(That is an example where a problem can be solved with both macro types).
|
||||
With C macros it is common to enclose the results in parentheses to
|
||||
prevent unintended interactions with the text of the arguments, but
|
||||
additional care must be taken in this assembly context where parentheses
|
||||
may alter the meaning of a statement. In particular, indirect addressing modes
|
||||
may be accidentally implied:
|
||||
|
||||
<tscreen><verb>
|
||||
.define DUO(ta,tb) (ta+(tb*10))
|
||||
|
||||
lda DUO(5,4), Y ; LDA (indirect), Y
|
||||
lda 0+DUO(5,4), Y ; LDA absolute indexed, Y
|
||||
</verb></tscreen>
|
||||
|
||||
|
||||
<sect1>Characters in macros<p>
|
||||
|
@ -67,7 +67,7 @@ Special locations:
|
||||
|
||||
<descrip>
|
||||
<tag/Stack/
|
||||
The C runtime stack is located at $FF81, and grows downwards.
|
||||
The C runtime stack is located at $FEC2, and grows downwards.
|
||||
|
||||
<tag/Heap/
|
||||
The C heap is located at the end of the program, and grows towards the C
|
||||
|
394
doc/cc65.sgml
394
doc/cc65.sgml
@ -4,7 +4,7 @@
|
||||
<title>cc65 Users Guide
|
||||
<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline>
|
||||
<url url="mailto:gregdk@users.sf.net" name="Greg King">
|
||||
<date>2016-06-11
|
||||
<date>2017-05-20
|
||||
|
||||
<abstract>
|
||||
cc65 is a C compiler for 6502 targets. It supports several 6502 based home
|
||||
@ -58,7 +58,7 @@ Short options:
|
||||
-O Optimize code
|
||||
-Oi Optimize code, inline more code
|
||||
-Or Enable register variables
|
||||
-Os Inline some known functions
|
||||
-Os Inline some standard functions
|
||||
-T Include source as comment
|
||||
-V Print the compiler version number
|
||||
-W warning[,...] Suppress warnings
|
||||
@ -88,9 +88,11 @@ Long options:
|
||||
--debug-opt name Debug optimization steps
|
||||
--dep-target target Use this dependency target
|
||||
--disable-opt name Disable an optimization step
|
||||
--eagerly-inline-funcs Eagerly inline some known functions
|
||||
--enable-opt name Enable an optimization step
|
||||
--help Help (this text)
|
||||
--include-dir dir Set an include directory search path
|
||||
--inline-stdfuncs Inline some standard functions
|
||||
--list-opt-steps List all optimizer steps and exit
|
||||
--list-warnings List available warning types for -W
|
||||
--local-strings Emit string literals immediately
|
||||
@ -219,11 +221,53 @@ Here is a description of all the command line options:
|
||||
symbols in a special section in the object file.
|
||||
|
||||
|
||||
<label id="option-eagerly-inline-funcs">
|
||||
<tag><tt>--eagerly-inline-funcs</tt></tag>
|
||||
|
||||
Have the compiler eagerly inline these functions from the C library:
|
||||
<itemize>
|
||||
<item><tt/memcpy()/
|
||||
<item><tt/memset()/
|
||||
<item><tt/strcmp()/
|
||||
<item><tt/strcpy()/
|
||||
<item><tt/strlen()/
|
||||
<item>most of the functions declared in <tt/<ctype.h>/
|
||||
</itemize>
|
||||
|
||||
Note: This has two consequences:
|
||||
<itemize>
|
||||
<item>You may not use names of standard C functions for your own functions.
|
||||
If you do that, your program is not standard-compliant anyway; but,
|
||||
using <tt/--eagerly-inline-funcs/ actually will break things.
|
||||
<p>
|
||||
<item>The inlined string and memory functions will not handle strings or
|
||||
memory areas larger than 255 bytes. Similarly, the inlined <tt/is..()/
|
||||
functions will not work with values outside the char. range (such as
|
||||
<tt/EOF/).
|
||||
<p>
|
||||
</itemize>
|
||||
|
||||
<tt/--eagerly-inline-funcs/ implies the <tt><ref id="option-inline-stdfuncs"
|
||||
name="--inline-stdfuncs"></tt> command line option.
|
||||
|
||||
See also <tt><ref id="pragma-allow-eager-inline" name="#pragma allow-eager-inline"></tt>.
|
||||
|
||||
|
||||
<tag><tt>-h, --help</tt></tag>
|
||||
|
||||
Print the short option summary shown above.
|
||||
|
||||
|
||||
<label id="option-inline-stdfuncs">
|
||||
<tag><tt>--inline-stdfuncs</tt></tag>
|
||||
|
||||
Allow the compiler to inline some standard functions from the C library like
|
||||
strlen. This will not only remove the overhead for a function call, but will
|
||||
make the code visible for the optimizer. See also the <tt><ref id="option-O"
|
||||
name="-Os"></tt> command line option and <tt><ref id="pragma-inline-stdfuncs"
|
||||
name="#pragma inline-stdfuncs"></tt>.
|
||||
|
||||
|
||||
<label id="option-list-warnings">
|
||||
<tag><tt>--list-warnings</tt></tag>
|
||||
|
||||
@ -392,22 +436,22 @@ Here is a description of all the command line options:
|
||||
using
|
||||
|
||||
<tscreen><verb>
|
||||
void f (void)
|
||||
{
|
||||
unsigned a = 1;
|
||||
...
|
||||
}
|
||||
void f (void)
|
||||
{
|
||||
unsigned a = 1;
|
||||
...
|
||||
}
|
||||
</verb></tscreen>
|
||||
|
||||
the variable <tt/a/ will always have the value <tt/1/ when entering the
|
||||
function and using <tt/-Cl/, while in
|
||||
|
||||
<tscreen><verb>
|
||||
void f (void)
|
||||
{
|
||||
static unsigned a = 1;
|
||||
....
|
||||
}
|
||||
void f (void)
|
||||
{
|
||||
static unsigned a = 1;
|
||||
....
|
||||
}
|
||||
</verb></tscreen>
|
||||
|
||||
the variable <tt/a/ will have the value <tt/1/ only the first time that the
|
||||
@ -444,23 +488,14 @@ Here is a description of all the command line options:
|
||||
name="--register-vars">/ command line option, and the <ref
|
||||
id="register-vars" name="discussion of register variables"> below.
|
||||
|
||||
Using <tt/-Os/ will force the compiler to inline some known functions from
|
||||
the C library like strlen. Note: This has two consequences:
|
||||
<p>
|
||||
<itemize>
|
||||
<item>You may not use names of standard C functions in your own code. If you
|
||||
do that, your program is not standard compliant anyway, but using
|
||||
<tt/-Os/ will actually break things.
|
||||
<p>
|
||||
<item>The inlined string and memory functions will not handle strings or
|
||||
memory areas larger than 255 bytes. Similarly, the inlined <tt/is..()/
|
||||
functions will not work with values outside the char. range (such as
|
||||
<tt/EOF/).
|
||||
<p>
|
||||
</itemize>
|
||||
<p>
|
||||
Using <tt/-Os/ will allow the compiler to inline some standard functions
|
||||
from the C library like strlen. This will not only remove the overhead
|
||||
for a function call, but will make the code visible for the optimizer.
|
||||
See also the <tt/<ref id="option-inline-stdfuncs" name="--inline-stdfuncs">/
|
||||
command line option.
|
||||
|
||||
It is possible to concatenate the modifiers for <tt/-O/. For example, to
|
||||
enable register variables and inlining of known functions, you may use
|
||||
enable register variables and inlining of standard functions, you may use
|
||||
<tt/-Ors/.
|
||||
|
||||
|
||||
@ -518,6 +553,7 @@ Here is a description of all the command line options:
|
||||
</descrip><p>
|
||||
|
||||
|
||||
|
||||
<sect>Input and output<p>
|
||||
|
||||
The compiler will accept one C file per invocation and create a file with
|
||||
@ -556,21 +592,21 @@ and the one defined by the ISO standard:
|
||||
|
||||
<itemize>
|
||||
|
||||
<item> The datatypes "float" and "double" are not available.
|
||||
<p>
|
||||
<item> C Functions may not return structs (or unions), and structs may not
|
||||
<item> The datatypes "float" and "double" are not available.
|
||||
<p>
|
||||
<item> C Functions may not return structs (or unions), and structs may not
|
||||
be passed as parameters by value. However, struct assignment *is*
|
||||
possible.
|
||||
<p>
|
||||
<item> Most of the C library is available with only the fastcall calling
|
||||
convention (<ref id="extension-fastcall" name="see below">). It means
|
||||
that you must not mix pointers to those functions with pointers to
|
||||
user-written, cdecl functions (the calling conventions are incompatible).
|
||||
<p>
|
||||
<item> The <tt/volatile/ keyword has almost no effect. That is not as bad
|
||||
possible.
|
||||
<p>
|
||||
<item> Most of the C library is available with only the fastcall calling
|
||||
convention (<ref id="extension-fastcall" name="see below">). It means
|
||||
that you must not mix pointers to those functions with pointers to
|
||||
user-written, cdecl functions (the calling conventions are incompatible).
|
||||
<p>
|
||||
<item> The <tt/volatile/ keyword has almost no effect. That is not as bad
|
||||
as it sounds, since the 6502 has so few registers that it isn't
|
||||
possible to keep values in registers anyway.
|
||||
<p>
|
||||
<p>
|
||||
</itemize>
|
||||
|
||||
There may be some more minor differences I'm currently not aware of. The
|
||||
@ -585,49 +621,48 @@ This cc65 version has some extensions to the ISO C standard.
|
||||
|
||||
<itemize>
|
||||
|
||||
<item> The compiler allows to insert assembler statements into the output
|
||||
file. The syntax is
|
||||
<item> The compiler allows to insert assembler statements into the output
|
||||
file. The syntax is
|
||||
|
||||
<tscreen><verb>
|
||||
asm [optional volatile] (<string literal>[, optional parameters]) ;
|
||||
</verb></tscreen>
|
||||
or
|
||||
<tscreen><verb>
|
||||
<tscreen><verb>
|
||||
asm [optional volatile] (<string literal>[, optional parameters]) ;
|
||||
</verb></tscreen>
|
||||
or
|
||||
<tscreen><verb>
|
||||
__asm__ [optional volatile] (<string literal>[, optional parameters]) ;
|
||||
</verb></tscreen>
|
||||
</verb></tscreen>
|
||||
|
||||
The first form is in the user namespace; and, is disabled if the <tt/-A/
|
||||
switch is given.
|
||||
The first form is in the user namespace; and, is disabled if the <tt/-A/
|
||||
switch is given.
|
||||
|
||||
There is a whole section covering inline assembler statements,
|
||||
<ref id="inline-asm" name="see there">.
|
||||
<p>
|
||||
There is a whole section covering inline assembler statements,
|
||||
<ref id="inline-asm" name="see there">.
|
||||
<p>
|
||||
|
||||
<label id="extension-fastcall">
|
||||
<item> The normal calling convention -- for non-variadic functions -- is
|
||||
named "fastcall". The syntax for a function declaration that
|
||||
<em/explicitly/ uses fastcall is
|
||||
<item> The normal calling convention -- for non-variadic functions -- is
|
||||
named "fastcall". The syntax for a function declaration that
|
||||
<em/explicitly/ uses fastcall is
|
||||
|
||||
<tscreen><verb>
|
||||
<return type> fastcall <function name> (<parameter list>)
|
||||
</verb></tscreen>
|
||||
or
|
||||
<tscreen><verb>
|
||||
<return type> __fastcall__ <function name> (<parameter list>)
|
||||
</verb></tscreen>
|
||||
An example is
|
||||
<tscreen><verb>
|
||||
void __fastcall__ f (unsigned char c)
|
||||
</verb></tscreen>
|
||||
The first form of the fastcall keyword is in the user namespace and can
|
||||
therefore be disabled with the <tt><ref id="option--standard"
|
||||
<tscreen><verb>
|
||||
<return type> fastcall <function name> (<parameter list>)
|
||||
</verb></tscreen>
|
||||
or
|
||||
<tscreen><verb>
|
||||
<return type> __fastcall__ <function name> (<parameter list>)
|
||||
</verb></tscreen>
|
||||
An example is
|
||||
<tscreen><verb>
|
||||
void __fastcall__ f (unsigned char c)
|
||||
</verb></tscreen>
|
||||
The first form of the fastcall keyword is in the user namespace and can
|
||||
therefore be disabled with the <tt><ref id="option--standard"
|
||||
name="--standard"></tt> command line option.
|
||||
|
||||
For functions that are <tt/fastcall/, the rightmost parameter is not
|
||||
pushed on the stack but left in the primary register when the function
|
||||
is called. That significantly reduces the cost of calling those functions.
|
||||
<newline><newline>
|
||||
<p>
|
||||
For functions that are <tt/fastcall/, the rightmost parameter is not
|
||||
pushed on the stack but left in the primary register when the function
|
||||
is called. That significantly reduces the cost of calling those functions.
|
||||
<p>
|
||||
|
||||
<item> There is another calling convention named "cdecl". Variadic functions
|
||||
(their prototypes have an ellipsis [<tt/.../]) always use that
|
||||
@ -652,65 +687,72 @@ This cc65 version has some extensions to the ISO C standard.
|
||||
For functions that are <tt/cdecl/, the rightmost parameter is pushed
|
||||
onto the stack before the function is called. That increases the cost
|
||||
of calling those functions, especially when they are called from many
|
||||
places.<newline><newline>
|
||||
places.
|
||||
<p>
|
||||
|
||||
<item> There are two pseudo variables named <tt/__AX__/ and <tt/__EAX__/.
|
||||
Both refer to the primary register that is used by the compiler to
|
||||
evaluate expressions or return function results. <tt/__AX__/ is of
|
||||
type <tt/unsigned int/ and <tt/__EAX__/ of type <tt/long unsigned int/
|
||||
respectively. The pseudo variables may be used as lvalue and rvalue as
|
||||
every other variable. They are most useful together with short
|
||||
sequences of assembler code. For example, the macro
|
||||
<item> There are two pseudo variables named <tt/__AX__/ and <tt/__EAX__/.
|
||||
Both refer to the primary register that is used by the compiler to
|
||||
evaluate expressions or return function results. <tt/__AX__/ is of
|
||||
type <tt/unsigned int/ and <tt/__EAX__/ of type <tt/long unsigned int/
|
||||
respectively. The pseudo variables may be used as lvalue and rvalue as
|
||||
every other variable. They are most useful together with short
|
||||
sequences of assembler code. For example, the macro
|
||||
|
||||
<tscreen><verb>
|
||||
#define hi(x) \
|
||||
<tscreen><verb>
|
||||
#define hi(x) \
|
||||
(__AX__ = (x), \
|
||||
asm ("txa"), \
|
||||
asm ("ldx #$00"), \
|
||||
__AX__)
|
||||
</verb></tscreen>
|
||||
</verb></tscreen>
|
||||
|
||||
will give the high byte of any unsigned value.
|
||||
<p>
|
||||
will give the high byte of any unsigned value.
|
||||
<p>
|
||||
|
||||
<item> Inside a function, the identifier <tt/__func__/ gives the name of the
|
||||
current function as a string. Outside of functions, <tt/__func__/ is
|
||||
undefined.
|
||||
Example:
|
||||
<item> Inside a function, the identifier <tt/__func__/ gives the name of the
|
||||
current function as a string. Outside of functions, <tt/__func__/ is
|
||||
undefined.
|
||||
Example:
|
||||
|
||||
<tscreen><verb>
|
||||
#define PRINT_DEBUG(s) printf ("%s: %s\n", __func__, s);
|
||||
</verb></tscreen>
|
||||
<tscreen><verb>
|
||||
#define PRINT_DEBUG(s) printf ("%s: %s\n", __func__, s);
|
||||
</verb></tscreen>
|
||||
|
||||
The macro will print the name of the current function plus a given
|
||||
string.
|
||||
<p>
|
||||
The macro will print the name of the current function plus a given
|
||||
string.
|
||||
<p>
|
||||
|
||||
<item> cc65 allows the initialization of <tt/void/ variables. This may be
|
||||
used to create variable structures that are more compatible with
|
||||
interfaces written for assembler languages. Here is an example:
|
||||
<item> cc65 allows the initialization of <tt/void/ variables. This may be
|
||||
used to create arbitrary structures that are more compatible with
|
||||
interfaces written for assembler languages. Here is an example:
|
||||
|
||||
<tscreen><verb>
|
||||
void GCmd = { (char)3, (unsigned)0x2000, (unsigned)0x3000 };
|
||||
</verb></tscreen>
|
||||
<tscreen><verb>
|
||||
void GCmd = { (char)3, (unsigned)0x2000, (unsigned)0x3000 };
|
||||
</verb></tscreen>
|
||||
|
||||
This will be translated as follows:
|
||||
That will be translated as follows:
|
||||
|
||||
<tscreen><verb>
|
||||
_GCmd:
|
||||
.byte 3
|
||||
.word $2000
|
||||
.word $3000
|
||||
</verb></tscreen>
|
||||
<tscreen><verb>
|
||||
_GCmd:
|
||||
.byte 3
|
||||
.word $2000
|
||||
.word $3000
|
||||
</verb></tscreen>
|
||||
|
||||
Since the variable is of type <tt/void/ you may not use it as is.
|
||||
However, taking the address of the variable results in a <tt/void*/
|
||||
which may be passed to any function expecting a pointer.
|
||||
Since the variable is of type <tt/void/, you may not use it as-is.
|
||||
However, taking the address of the variable results in a <tt/void*/
|
||||
which may be passed to any function expecting a pointer. Also, the
|
||||
<tt/sizeof/ operator will give the length of the initializer:
|
||||
|
||||
See the <url url="geos.html" name="GEOS library document"> for examples
|
||||
on how to use this feature.
|
||||
<p>
|
||||
<tscreen><verb>
|
||||
GLen = sizeof GCmd;
|
||||
</verb></tscreen>
|
||||
|
||||
will assign the value 5 to <tt/GLen/.
|
||||
|
||||
See the <url url="geos.html" name="GEOS library document"> for examples
|
||||
on how to use that feature.
|
||||
<p>
|
||||
|
||||
<item> cc65 implements flexible array struct members as defined in the C99 ISO
|
||||
standard. As an extension, these fields may be initialized. There are
|
||||
@ -818,6 +860,11 @@ The compiler defines several macros at startup:
|
||||
This macro expands to the date of translation of the preprocessing
|
||||
translation unit in the form "Mmm dd yyyy".
|
||||
|
||||
<tag><tt>__EAGERLY_INLINE_FUNCS__</tt></tag>
|
||||
|
||||
Is defined if the compiler was called with the <tt><ref id="option-eagerly-inline-funcs"
|
||||
name="--eagerly-inline-funcs"></tt> command line option.
|
||||
|
||||
<tag><tt>__FILE__</tt></tag>
|
||||
|
||||
This macro expands to a string containing the name of the C source file.
|
||||
@ -905,6 +952,7 @@ The compiler defines several macros at startup:
|
||||
</descrip>
|
||||
|
||||
|
||||
|
||||
<sect>#pragmas<label id="pragmas"><p>
|
||||
|
||||
The compiler understands some pragmas that may be used to change code
|
||||
@ -913,6 +961,19 @@ If the first parameter is <tt/push/, the old value is saved onto a stack
|
||||
before changing it. The value may later be restored by using the <tt/pop/
|
||||
parameter with the <tt/#pragma/.
|
||||
|
||||
|
||||
<sect1><tt>#pragma allow-eager-inline ([push,] on|off)</tt><label id="pragma-allow-eager-inline"><p>
|
||||
|
||||
Allow eager inlining of known functions. If the argument is "off", eager
|
||||
inlining is disabled, otherwise it is enabled. Please note that (in contrast
|
||||
to the <tt><ref id="option-eagerly-inline-funcs" name="--eagerly-inline-funcs"></tt>
|
||||
command line option) this pragma does not imply the <tt><ref id="option-inline-stdfuncs"
|
||||
name="--inline-stdfuncs"></tt> command line option. Rather it marks code to be safe for
|
||||
eager inlining of known functions if inlining of standard functions is enabled.
|
||||
|
||||
The <tt/#pragma/ understands the push and pop parameters as explained above.
|
||||
|
||||
|
||||
<sect1><tt>#pragma bss-name ([push,] <name>)</tt><label id="pragma-bss-name"><p>
|
||||
|
||||
This pragma changes the name used for the BSS segment (the BSS segment
|
||||
@ -931,7 +992,7 @@ parameter with the <tt/#pragma/.
|
||||
|
||||
Example:
|
||||
<tscreen><verb>
|
||||
#pragma bss-name ("MyBSS")
|
||||
#pragma bss-name ("MyBSS")
|
||||
</verb></tscreen>
|
||||
|
||||
|
||||
@ -986,6 +1047,7 @@ parameter with the <tt/#pragma/.
|
||||
|
||||
The <tt/#pragma/ understands the push and pop parameters as explained above.
|
||||
|
||||
|
||||
<sect1><tt>#pragma code-name ([push,] <name>)</tt><label id="pragma-code-name"><p>
|
||||
|
||||
This pragma changes the name used for the CODE segment (the CODE segment
|
||||
@ -1000,7 +1062,7 @@ parameter with the <tt/#pragma/.
|
||||
|
||||
Example:
|
||||
<tscreen><verb>
|
||||
#pragma code-name ("MyCODE")
|
||||
#pragma code-name ("MyCODE")
|
||||
</verb></tscreen>
|
||||
|
||||
|
||||
@ -1028,10 +1090,21 @@ parameter with the <tt/#pragma/.
|
||||
|
||||
Example:
|
||||
<tscreen><verb>
|
||||
#pragma data-name ("MyDATA")
|
||||
#pragma data-name ("MyDATA")
|
||||
</verb></tscreen>
|
||||
|
||||
|
||||
<sect1><tt>#pragma inline-stdfuncs ([push,] on|off)</tt><label id="pragma-inline-stdfuncs"><p>
|
||||
|
||||
Allow the compiler to inline some standard functions from the C library like
|
||||
strlen. If the argument is "off", inlining is disabled, otherwise it is enabled.
|
||||
|
||||
See also the <tt/<ref id="option-inline-stdfuncs" name="--inline-stdfuncs">/
|
||||
command line option.
|
||||
|
||||
The <tt/#pragma/ understands the push and pop parameters as explained above.
|
||||
|
||||
|
||||
<sect1><tt>#pragma local-strings ([push,] on|off)</tt><label id="pragma-local-strings"><p>
|
||||
|
||||
When "on", emit string literals to the data segment when they're encountered
|
||||
@ -1046,6 +1119,23 @@ parameter with the <tt/#pragma/.
|
||||
remembered and output as a whole when translation is finished.
|
||||
|
||||
|
||||
<sect1><tt>#pragma message (<message>)</tt><label id="pragma-message"><p>
|
||||
|
||||
This pragma is used to display informational messages at compile-time.
|
||||
|
||||
The message intented to be displayed must be a string literal.
|
||||
|
||||
Example:
|
||||
<tscreen><verb>
|
||||
#pragma message ("in a bottle")
|
||||
</verb></tscreen>
|
||||
|
||||
Results in the compiler outputting the following to stderr:
|
||||
<tscreen><verb>
|
||||
example.c(42): Note: in a bottle
|
||||
</verb></tscreen>
|
||||
|
||||
|
||||
<sect1><tt>#pragma optimize ([push,] on|off)</tt><label id="pragma-optimize"><p>
|
||||
|
||||
Switch optimization on or off. If the argument is "off", optimization is
|
||||
@ -1076,7 +1166,7 @@ parameter with the <tt/#pragma/.
|
||||
|
||||
Example:
|
||||
<tscreen><verb>
|
||||
#pragma rodata-name ("MyRODATA")
|
||||
#pragma rodata-name ("MyRODATA")
|
||||
</verb></tscreen>
|
||||
|
||||
|
||||
@ -1098,9 +1188,9 @@ parameter with the <tt/#pragma/.
|
||||
|
||||
Example:
|
||||
<tscreen><verb>
|
||||
#pragma regvaraddr(on) /* Allow taking the address
|
||||
* of register variables
|
||||
*/
|
||||
#pragma regvaraddr(on) /* Allow taking the address
|
||||
* of register variables
|
||||
*/
|
||||
</verb></tscreen>
|
||||
|
||||
|
||||
@ -1147,7 +1237,7 @@ parameter with the <tt/#pragma/.
|
||||
Example:
|
||||
<tscreen><verb>
|
||||
/* Don't warn about the unused parameter in function func */
|
||||
#pragma warn (unused-param, push, off)
|
||||
#pragma warn (unused-param, push, off)
|
||||
static int func (int unused)
|
||||
{
|
||||
return 0;
|
||||
@ -1156,6 +1246,39 @@ parameter with the <tt/#pragma/.
|
||||
</verb></tscreen>
|
||||
|
||||
|
||||
<sect1><tt>#pragma wrapped-call (push, <name>, <identifier>)</tt><label id="pragma-wrapped-call"><p>
|
||||
|
||||
This pragma sets a wrapper for functions, often used for trampolines.
|
||||
|
||||
The name is a function returning <tt/void/, and taking no parameters.
|
||||
It must preserve the CPU's <tt/A/ and <tt/X/ registers if it wraps any
|
||||
<tt/__fastcall__/ functions that have parameters. It must preserve
|
||||
the <tt/Y/ register if it wraps any variadic functions (they have "<tt/.../"
|
||||
in their prototypes).
|
||||
|
||||
The identifier is an 8-bit number that's set into <tt/tmp4/.
|
||||
|
||||
The address of a wrapped function is passed in <tt/ptr4/. The wrapper can
|
||||
call that function by using "<tt/jsr callptr4/".
|
||||
|
||||
This feature is useful, for example, with banked memory, to switch banks
|
||||
automatically to where a wrapped function resides, and then to restore the
|
||||
previous bank when it returns.
|
||||
|
||||
The <tt/#pragma/ requires the push or pop argument as explained above.
|
||||
|
||||
Example:
|
||||
<tscreen><verb>
|
||||
/* Note that this code can be in a header. */
|
||||
void mytrampoline(void); /* Doesn't corrupt __AX__ */
|
||||
|
||||
#pragma wrapped-call (push, mytrampoline, 5)
|
||||
void somefunc1(void);
|
||||
void somefunc2(int, char *);
|
||||
#pragma wrapped-call (pop)
|
||||
</verb></tscreen>
|
||||
|
||||
|
||||
<sect1><tt>#pragma writable-strings ([push,] on|off)</tt><label id="pragma-writable-strings"><p>
|
||||
|
||||
Changes the storage location of string literals. For historical reasons,
|
||||
@ -1180,13 +1303,12 @@ parameter with the <tt/#pragma/.
|
||||
|
||||
Example:
|
||||
<tscreen><verb>
|
||||
extern int foo;
|
||||
#pragma zpsym ("foo"); /* foo is in the zeropage */
|
||||
extern int foo;
|
||||
#pragma zpsym ("foo"); /* foo is in the zeropage */
|
||||
</verb></tscreen>
|
||||
|
||||
|
||||
|
||||
|
||||
<sect>Register variables<label id="register-vars"><p>
|
||||
|
||||
The runtime for all supported platforms has 6 bytes of zero page space
|
||||
@ -1269,7 +1391,7 @@ that function).
|
||||
As a shortcut, you can put the <tt/volatile/ qualifier in your <tt/asm/
|
||||
statements. It will disable optimization for the functions in which those
|
||||
<tt/asm volatile/ statements sit. The effect is the same as though you put
|
||||
</#pragma optimize(push, off)/ above those functions, and </#pragma
|
||||
<tt/#pragma optimize(push, off)/ above those functions, and <tt/#pragma
|
||||
optimize(pop)/ below those functions.
|
||||
|
||||
The string literal may contain format specifiers from the following list. For
|
||||
@ -1443,14 +1565,14 @@ including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
<enum>
|
||||
<item> The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
<item> Altered source versions must be plainly marked as such, and must not
|
||||
be misrepresented as being the original software.
|
||||
<item> This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
<item> The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
<item> Altered source versions must be plainly marked as such, and must not
|
||||
be misrepresented as being the original software.
|
||||
<item> This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
</enum>
|
||||
|
||||
</article>
|
||||
|
@ -2,8 +2,9 @@
|
||||
|
||||
<article>
|
||||
<title>cl65 Users Guide
|
||||
<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">
|
||||
<date>01.08.2000, 27.11.2000, 02.10.2001
|
||||
<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline>
|
||||
<url url="mailto:greg.king5@verizon.net" name="Greg King">
|
||||
<date>2017-10-16
|
||||
|
||||
<abstract>
|
||||
cl65 is the compile & link utility for cc65, the 6502 C compiler. It was
|
||||
@ -50,13 +51,14 @@ Short options:
|
||||
-C name Use linker config file
|
||||
-Cl Make local variables static
|
||||
-D sym[=defn] Define a preprocessor symbol
|
||||
-E Stop after the preprocessing stage
|
||||
-I dir Set a compiler include directory path
|
||||
-L path Specify a library search path
|
||||
-Ln name Create a VICE label file
|
||||
-O Optimize code
|
||||
-Oi Optimize code, inline functions
|
||||
-Oi Optimize code, inline more code
|
||||
-Or Optimize code, honour the register keyword
|
||||
-Os Optimize code, inline known C funtions
|
||||
-Os Optimize code, inline standard funtions
|
||||
-S Compile but don't assemble and link
|
||||
-T Include source as comment
|
||||
-V Print the version number
|
||||
@ -67,6 +69,7 @@ Short options:
|
||||
|
||||
Long options:
|
||||
--add-source Include source as comment
|
||||
--all-cdecl Make functions default to __cdecl__
|
||||
--asm-args options Pass options to the assembler
|
||||
--asm-define sym[=v] Define an assembler symbol
|
||||
--asm-include-dir dir Set an assembler include directory
|
||||
@ -120,56 +123,66 @@ Long options:
|
||||
---------------------------------------------------------------------------
|
||||
</verb></tscreen>
|
||||
|
||||
Most of the options have the same meaning than the corresponding compiler,
|
||||
assembler or linker option. See the documentation for these tools for an
|
||||
Most of the options have the same meanings as the corresponding compiler,
|
||||
assembler, and linker options. See the documentation for those tools for an
|
||||
explanation. If an option is available for more than one of the tools, it
|
||||
is set for all tools, where it is available. One example for this is <tt/-v/:
|
||||
The compiler, the assembler and the linker are all called with the <tt/-v/
|
||||
is set for all tools where it is available. One example for that is <tt/-v/:
|
||||
The compiler, the assembler, and the linker are all called with the <tt/-v/
|
||||
switch.
|
||||
|
||||
There are a few remaining options that control the behaviour of cl65:
|
||||
|
||||
<descrip>
|
||||
|
||||
<tag><tt>-E</tt></tag>
|
||||
|
||||
This option is passed to the cc65 compiler; and, it forces cl65 to stop
|
||||
before the assembly step. That means that C-level preprocessor directives
|
||||
are obeyed; and, macroes are expanded. But, the C source isn't compiled.
|
||||
If the <tt/-o/ option isn't used, then the C code results are written into
|
||||
files with a ".i" suffix on their base names. Assembler files, object
|
||||
files, and libraries given on the command line are ignored.
|
||||
|
||||
|
||||
<tag><tt>-S</tt></tag>
|
||||
|
||||
This option forces cl65 to stop after the assembly step. This means that
|
||||
C files are translated into assembler files, but nothing more is done.
|
||||
Assembler files, object files and libraries given on the command line
|
||||
This option forces cl65 to stop before the assembly step. That means that
|
||||
C files are translated into assembler files; but, nothing more is done.
|
||||
Assembler files, object files, and libraries given on the command line
|
||||
are ignored.
|
||||
|
||||
|
||||
<tag><tt>-c</tt></tag>
|
||||
|
||||
This options forces cl65 to stop after the assembly step. This means
|
||||
This option forces cl65 to stop after the assembly step. That means
|
||||
that C and assembler files given on the command line are translated into
|
||||
object files, but there is no link step, and object files and libraries
|
||||
object files; but, there is no link step. Object files and libraries
|
||||
given on the command line are ignored.
|
||||
|
||||
|
||||
<tag><tt>-o name</tt></tag>
|
||||
|
||||
The -o option is used for the target name in the final step. This causes
|
||||
problems, if the linker will not be called, and there are several input
|
||||
files on the command line. In this case, the name given with -o will be
|
||||
The -o option is used for the target name in the final step. That causes
|
||||
problems if the linker will not be called, and there are several input
|
||||
files on the command line. In that case, the name given with -o will be
|
||||
used for all of them, which makes the option pretty useless. You
|
||||
shouldn't use -o when more than one output file is created.
|
||||
shouldn't use <tt/-o/ when more than one output file is created.
|
||||
|
||||
|
||||
<tag><tt>--print-target-path</tt></tag>
|
||||
|
||||
This option prints the absolute path of the target file directory and exits
|
||||
This option prints the absolute path of the target file directory, and exits
|
||||
then. It is supposed to be used with shell backquotes or the GNU make shell
|
||||
function. This way you can write build scripts or Makefiles accessing target
|
||||
function. That way, you can write build scripts or Makefiles accessing target
|
||||
files without any assumption about the cc65 installation path.
|
||||
|
||||
|
||||
<tag><tt>-t sys, --target sys</tt></tag>
|
||||
|
||||
The default for this option is different from the compiler and linker in the
|
||||
case that the option is missing: While the other tools (compiler, assembler
|
||||
The default for this option is different from the compiler and linker, in the
|
||||
case that the option is missing: While the other tools (compiler, assembler,
|
||||
and linker) will use the "none" system settings by default, cl65 will use
|
||||
the C64 as a target system by default. This was chosen since most people
|
||||
"c64" as a target system by default. That was chosen because most people
|
||||
seem to use cc65 to develop for the C64.
|
||||
|
||||
|
||||
@ -177,10 +190,10 @@ There are a few remaining options that control the behaviour of cl65:
|
||||
|
||||
Pass options directly to the assembler. This may be used to pass options
|
||||
that aren't directly supported by cl65. Several options may be separated by
|
||||
commas, the commas are replaced by spaces when passing them to the
|
||||
assembler. Beware: Passing arguments directly to the assembler may interfere
|
||||
with some of the defaults, because cl65 doesn't parse the options passed. So
|
||||
if cl65 supports an option by itself, do not pass this option to the
|
||||
commas; the commas are replaced by spaces when passing them to the
|
||||
assembler. Beware: Passing arguments directly to the assembler might interfere
|
||||
with some of the defaults because cl65 doesn't parse the options passed. So,
|
||||
if cl65 supports an option by itself, do not pass that option to the
|
||||
assembler by means of the <tt/-Wa/ switch.
|
||||
|
||||
|
||||
@ -188,10 +201,10 @@ There are a few remaining options that control the behaviour of cl65:
|
||||
|
||||
Pass options directly to the compiler. This may be used to pass options
|
||||
that aren't directly supported by cl65. Several options may be separated by
|
||||
commas, the commas are replaced by spaces when passing them to the
|
||||
compiler. Beware: Passing arguments directly to the compiler may interfere
|
||||
with some of the defaults, because cl65 doesn't parse the options passed. So
|
||||
if cl65 supports an option by itself, do not pass this option to the
|
||||
commas; the commas are replaced by spaces when passing them to the
|
||||
compiler. Beware: Passing arguments directly to the compiler might interfere
|
||||
with some of the defaults because cl65 doesn't parse the options passed. So,
|
||||
if cl65 supports an option by itself, do not pass that option to the
|
||||
compiler by means of the <tt/-Wc/ switch.
|
||||
|
||||
|
||||
@ -199,10 +212,10 @@ There are a few remaining options that control the behaviour of cl65:
|
||||
|
||||
Pass options directly to the linker. This may be used to pass options that
|
||||
aren't directly supported by cl65. Several options may be separated by
|
||||
commas, the commas are replaced by spaces when passing them to the linker.
|
||||
Beware: Passing arguments directly to the linker may interfere with some of
|
||||
the defaults, because cl65 doesn't parse the options passed. So if cl65
|
||||
supports an option by itself, do not pass this option to the linker by means
|
||||
commas; the commas are replaced by spaces when passing them to the linker.
|
||||
Beware: Passing arguments directly to the linker might interfere with some of
|
||||
the defaults because cl65 doesn't parse the options passed. So, if cl65
|
||||
supports an option by itself, do not pass that option to the linker by means
|
||||
of the <tt/-Wl/ switch.
|
||||
|
||||
</descrip>
|
||||
@ -211,7 +224,7 @@ There are a few remaining options that control the behaviour of cl65:
|
||||
|
||||
<sect>More usage<p>
|
||||
|
||||
Since cl65 was created to simplify the use of the cc65 development
|
||||
Because cl65 was created to simplify the use of the cc65 development
|
||||
package, it tries to be smart about several things.
|
||||
|
||||
<itemize>
|
||||
@ -219,15 +232,14 @@ package, it tries to be smart about several things.
|
||||
<item> If you don't give a target system on the command line, cl65
|
||||
defaults to the C64.
|
||||
|
||||
<item> When linking, cl65 will supply the names of the startup file and
|
||||
library for the target system to the linker, so you don't have to do
|
||||
that.
|
||||
<item> When linking, cl65 will supply the name of the library file for
|
||||
the target system to the linker; so, you don't have to do that.
|
||||
|
||||
<item> If the final step is the linker, and the name of the output file was
|
||||
not explicitly given, cl65 will use the name of the first input file
|
||||
without the extension, provided that the name of this file has an
|
||||
extension. So you don't need to name the executable name in most
|
||||
cases, just give the name of your "main" file as first input file.
|
||||
without the extension, provided that the name of that file has an
|
||||
extension. So, you don't need to give the executable name in most
|
||||
cases; just give the name of your "main" file as the first input file.
|
||||
</itemize>
|
||||
|
||||
The command line is parsed from left to right, and the actual processing tool
|
||||
@ -248,7 +260,7 @@ The type of an input file is derived from its extension:
|
||||
<itemize>
|
||||
<item>C files: <tt/.c/
|
||||
<item>Assembler files: <tt/.s/, <tt/.asm/, <tt/.a65/
|
||||
<item>Object files: <tt/.o/ <tt/.obj/
|
||||
<item>Object files: <tt/.o/, <tt/.obj/
|
||||
<item>Libraries: <tt/.a/, <tt/.lib/
|
||||
<item>GEOS resource files: <tt/.grc/
|
||||
<item>o65 files: <tt/.o65/, <tt/.emd/, <tt/.joy/, <tt/.tgi/
|
||||
|
@ -2,8 +2,9 @@
|
||||
|
||||
<article>
|
||||
<title>cc65 function reference
|
||||
<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">
|
||||
<date>2016-08-07
|
||||
<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline>
|
||||
<url url="mailto:greg.king5@verizon.net" name="Greg King">
|
||||
<date>2017-09-02
|
||||
|
||||
<abstract>
|
||||
cc65 is a C compiler for 6502 based systems. This function reference describes
|
||||
@ -183,6 +184,7 @@ function.
|
||||
<!-- <item><ref id="cbm_save" name="cbm_save"> -->
|
||||
<!-- <item><ref id="cbm_write" name="cbm_write"> -->
|
||||
<!-- <item><ref id="get_tv" name="get_tv"> -->
|
||||
<item><ref id="kbrepeat" name="kbrepeat">
|
||||
</itemize>
|
||||
|
||||
(incomplete)
|
||||
@ -398,6 +400,13 @@ function.
|
||||
(incomplete)
|
||||
|
||||
|
||||
<sect1><tt/lz4.h/<label id="lz4.h"><p>
|
||||
|
||||
<itemize>
|
||||
<item><ref id="decompress_lz4" name="decompress_lz4">
|
||||
</itemize>
|
||||
|
||||
|
||||
<sect1><tt/modload.h/<label id="modload.h"><p>
|
||||
|
||||
<itemize>
|
||||
@ -430,7 +439,7 @@ function.
|
||||
|
||||
<!-- <itemize> -->
|
||||
<!-- <item><ref id="get_tv" name="get_tv"> -->
|
||||
<!-- <item><ref id="waitvblank" name="waitvblank"> -->
|
||||
<!-- <item><ref id="waitvsync" name="waitvsync"> -->
|
||||
<!-- </itemize> -->
|
||||
|
||||
(incomplete)
|
||||
@ -2632,6 +2641,23 @@ used in presence of a prototype.
|
||||
</quote>
|
||||
|
||||
|
||||
<sect1>decompress_lz4<label id="decompress_lz4"><p>
|
||||
|
||||
<quote>
|
||||
<descrip>
|
||||
<tag/Function/Uncompress a LZ4-compressed buffer.
|
||||
<tag/Header/<tt/<ref id="lz4.h" name="lz4.h">/
|
||||
<tag/Declaration/<tt/void decompress_lz4 (const unsigned char* src, unsigned char* const dst, const unsigned short uncompressed_size);/
|
||||
<tag/Description/<tt/decompress_lz4/ uncompresses a LZ4-compressed buffer.
|
||||
<tag/Notes/<itemize>
|
||||
<item>Use LZ4_compress_HC with compression level 16 for best compression.
|
||||
</itemize>
|
||||
<tag/Availability/cc65
|
||||
<tag/Example/None.
|
||||
</descrip>
|
||||
</quote>
|
||||
|
||||
|
||||
<sect1>div<label id="div"><p>
|
||||
|
||||
<quote>
|
||||
@ -3710,7 +3736,7 @@ fastcall function, so it may only be used in presence of a prototype.
|
||||
|
||||
<quote>
|
||||
<descrip>
|
||||
<tag/Function/Check if a given character is a a white-space character.
|
||||
<tag/Function/Check if a given character is a white-space character.
|
||||
<tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
|
||||
<tag/Declaration/<tt/int __fastcall__ isspace (int c);/
|
||||
<tag/Description/The function returns a non zero value if the given argument
|
||||
@ -4017,6 +4043,28 @@ do), the function is rather useless.
|
||||
</quote>
|
||||
|
||||
|
||||
<sect1>kbrepeat<label id="kbrepeat"><p>
|
||||
|
||||
<quote>
|
||||
<descrip>
|
||||
<tag/Function/Set the keyboard repeat mode.
|
||||
<tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
|
||||
<tag/Declaration/<tt/unsigned char __fastcall__ kbrepeat (unsigned char mode);/
|
||||
<tag/Description/This function changes which keys have automatic repeat when
|
||||
being held down for a certain time. Possible values are <tt/KBREPEAT_CURSOR/
|
||||
(repeat only cursor-related keys), <tt/KBREPEAT_NONE/ (no repeat for any
|
||||
keys), and <tt/KBREPEAT_ALL/ (repeat all keys). The old mode is returned, so
|
||||
it can be restored later.
|
||||
<tag/Notes/<itemize>
|
||||
<item>The function is available only as a fastcall function; so, it may be used
|
||||
only in the presence of a prototype.
|
||||
</itemize>
|
||||
<tag/Availability/cc65
|
||||
<tag/Example/None.
|
||||
</descrip>
|
||||
</quote>
|
||||
|
||||
|
||||
<sect1>labs<label id="labs"><p>
|
||||
|
||||
<quote>
|
||||
|
@ -247,10 +247,11 @@ Here is a description of all of the command-line options:
|
||||
<tag><tt>-Ln</tt></tag>
|
||||
|
||||
This option allows you to create a file that contains all global labels and
|
||||
may be loaded into the VICE emulator using the <tt/ll/ (load label) command. You
|
||||
may be loaded into the VICE emulator using the <tt/ll/ (load label) command
|
||||
or into the Oricutron emulator using the <tt/sl/ (symbols load) command. You
|
||||
may use this to debug your code with VICE. Note: Older versions had some
|
||||
bugs in the label code. If you have problems, please get the latest <url
|
||||
url="http://vice-emu.sourceforge.net/" name="VICE"> version.
|
||||
url="http://vice-emu.sourceforge.net" name="VICE"> version.
|
||||
|
||||
|
||||
<label id="option-S">
|
||||
|
@ -69,8 +69,8 @@ Programs containing NES specific code may use the <tt/nes.h/ header file.
|
||||
<sect1>NES specific functions<p>
|
||||
|
||||
<itemize>
|
||||
<item>waitvblank - wait until the start of vblank
|
||||
<item>get_tv
|
||||
<item>waitvsync - wait until the start of the next frame</item>
|
||||
<item>get_tv</item>
|
||||
</itemize>
|
||||
|
||||
|
||||
|
@ -77,7 +77,7 @@ Programs containing PCE specific code may use the <tt/pce.h/ header file.
|
||||
<sect1>PCE specific functions<p>
|
||||
|
||||
<itemize>
|
||||
<item>waitvblank</item>
|
||||
<item>waitvsync</item>
|
||||
<item>get_tv (since all PCE systems are NTSC, this always returns TV_NTSC)</item>
|
||||
</itemize>
|
||||
|
||||
|
@ -66,7 +66,7 @@ Programs containing Supervision specific code may use the <tt/supervision.h/ hea
|
||||
<sect1>Supervision specific functions<p>
|
||||
|
||||
<itemize>
|
||||
<item>waitvblank
|
||||
<item>waitvsync</item>
|
||||
</itemize>
|
||||
|
||||
|
||||
|
@ -4,13 +4,15 @@
|
||||
|
||||
<title>Oric Telestrat-specific information for cc65
|
||||
<author>
|
||||
<url url="mailto:jede@oric.org" name="Jede">,<newline>
|
||||
<url url="mailto:jede@oric.org" name="Jede">
|
||||
|
||||
<date>2017-01-22
|
||||
|
||||
<abstract>
|
||||
|
||||
An overview over the Telestrat (Telemon 2.4 & Telemon 3.x : http://orix.oric.org) runtime system as it is implemented for the cc65 C
|
||||
compiler.)
|
||||
|
||||
</abstract>
|
||||
|
||||
<!-- Table of contents -->
|
||||
@ -32,25 +34,28 @@ information.
|
||||
|
||||
<sect>Binary format<p>
|
||||
|
||||
The standard binary output format generated the linker for the Telestrat target
|
||||
is a machine language program with a 20 bytes header described here : http://orix.oric.org/doku.php?id=orix:header
|
||||
The standard binary output format generated the linker for the Telestrat
|
||||
target is a machine language program with a 20 bytes header described <url
|
||||
name="here" url="http://orix.oric.org/doku.php?id=orix:header">
|
||||
|
||||
This header is used for Telemon 3.0.
|
||||
This header is used for Telemon 3.0.
|
||||
|
||||
Anyway, for Telemon 2.4, there is no file management, there is no TAPE routine in Telemon, there is no way to load a binary easily.
|
||||
Anyway, for Telemon 2.4, there is no file management, there is no TAPE routine in Telemon, there is no way to load a binary easily.
|
||||
|
||||
Stratsed (the Telestrat operating system) handles files management. Stratsed is loaded to memory from floppy disk.
|
||||
Stratsed (the Telestrat operating system) handles files management. Stratsed is loaded to memory from floppy disk.
|
||||
|
||||
There is no tool to insert a binary in a Stratsed floppy disk.
|
||||
There is no tool to insert a binary in a Stratsed floppy disk.
|
||||
|
||||
The only way to load a binary (for Telemon 2.4) is to :
|
||||
The only way to load a binary (for Telemon 2.4) is to:
|
||||
<itemize>
|
||||
<item>remove the 20 bytes header
|
||||
<item>download osdk : http://osdk.defence-force.org/index?page=download
|
||||
<item>download <url name="osdk" url="http://osdk.defence-force.org/index?page=download">
|
||||
<item>use Floppybuilder in OSDK to insert the binary with the tool (please read FloppyBuilder manual to insert your binary, and to start microdisc boot sector when Telestrat starts)
|
||||
</itemize>
|
||||
|
||||
Please note also, that the binary converted into TAP file, will not produce a right stratsed file when tap2dsk and old2mfm are used. You will be in the case that Telestrat/Stratsed crashed when you do "DIR" command.
|
||||
Please note also, that the binary converted into TAP file, will not produce
|
||||
a right stratsed file when tap2dsk and old2mfm are used. You will be in the
|
||||
case that Telestrat/Stratsed crashed when you do "DIR" command.
|
||||
|
||||
If you know the Stratsed disk format, please contact the author of this doc.
|
||||
|
||||
@ -79,7 +84,7 @@ Special locations:
|
||||
|
||||
<sect>Platform-specific header files<p>
|
||||
|
||||
Programs containing Telestrat -specific code may use the <tt/telestrat.h/ header file.
|
||||
Programs containing Telestrat-specific code may use the <tt/telestrat.h/ header file.
|
||||
|
||||
|
||||
<sect1>Telestrat-specific functions<p>
|
||||
@ -162,8 +167,12 @@ Telestrat has a RS232 port, but it's not usable in cc65.
|
||||
|
||||
<sect1>Disk I/O<p>
|
||||
|
||||
Telemon 3.0 handles fopen, fread, fclose primitives. It means that this function will crash the Telestrat because Telemon 2.4 does not have these primitives.
|
||||
By the way, Telemon 3.0 uses an extension "ch376 card" which handles sdcard and FAT 32 usb key. In the next version of Telemon, FT DOS, Sedoric, Stratsed will be handled in these 3 primitives (fopen, fread, fclose).
|
||||
Telemon 3.0 handles fopen, fread, fclose primitives. It means that this
|
||||
function will crash the Telestrat because Telemon 2.4 does not have these
|
||||
primitives. By the way, Telemon 3.0 uses an extension "ch376 card" which
|
||||
handles sdcard and FAT 32 usb key. In the next version of Telemon, FT DOS,
|
||||
Sedoric, Stratsed will be handled in these 3 primitives (fopen, fread,
|
||||
fclose).
|
||||
|
||||
<itemize>
|
||||
<item>fclose
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
<article>
|
||||
|
||||
<title>Commodore VIC20 (aka VC20) specific information for cc65
|
||||
<title>Commodore VIC20 (aka VC20 aka VIC1001) specific information for cc65
|
||||
<author>
|
||||
<url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline>
|
||||
<url url="mailto:polluks@sdf.lonestar.org" name="Stefan A. Haubenthal">
|
||||
<date>2014-04-12
|
||||
<date>2017-05-18
|
||||
|
||||
<abstract>
|
||||
An overview over the VIC20 runtime system as it is implemented for the cc65 C
|
||||
@ -182,13 +182,14 @@ No VIC1011 drivers are currently available for the VIC20.
|
||||
<sect>Limitations<p>
|
||||
|
||||
|
||||
|
||||
<sect>Other hints<p>
|
||||
|
||||
|
||||
<sect1>Escape code<p>
|
||||
|
||||
For an Esc, press CTRL and the <tt/[/ key.
|
||||
The CTRL key cannot be used to type most control characters,
|
||||
entering an Esc is not possible.
|
||||
|
||||
|
||||
|
||||
<sect>Other hints<p>
|
||||
|
||||
|
||||
<sect1>Passing arguments to the program<p>
|
||||
@ -219,8 +220,7 @@ The program return code (low byte) is passed back to BASIC by use of the
|
||||
|
||||
<sect1>Using extended memory<p>
|
||||
|
||||
The extended memory at $A000 may be added to the heap by using the following
|
||||
code:
|
||||
BLK5 memory may be added to the heap by using the following code:
|
||||
|
||||
<tscreen><verb>
|
||||
/* Check for the existence of RAM */
|
||||
|
@ -42,6 +42,7 @@
|
||||
#endif
|
||||
|
||||
|
||||
#include <apple2_filetype.h>
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Data */
|
||||
@ -90,6 +91,14 @@
|
||||
#define CH_RTEE '+'
|
||||
#define CH_CROSS '+'
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x10
|
||||
#define JOY_DOWN_MASK 0x20
|
||||
#define JOY_LEFT_MASK 0x04
|
||||
#define JOY_RIGHT_MASK 0x08
|
||||
#define JOY_BTN_1_MASK 0x40
|
||||
#define JOY_BTN_2_MASK 0x80
|
||||
|
||||
/* Return codes for get_ostype */
|
||||
#define APPLE_UNKNOWN 0x00
|
||||
#define APPLE_II 0x10 /* Apple ][ */
|
||||
@ -136,11 +145,9 @@ extern unsigned char _dos_type;
|
||||
|
||||
|
||||
/* The file stream implementation and the POSIX I/O functions will use the
|
||||
** following variables to determine the file type, aux type and creation time
|
||||
** stamp to use.
|
||||
** following struct to set the date and time stamp on files. This specificially
|
||||
** applies to the open and fopen functions.
|
||||
*/
|
||||
extern unsigned char _filetype; /* Default: 6 */
|
||||
extern unsigned int _auxtype; /* Default: 0 */
|
||||
extern struct {
|
||||
struct {
|
||||
unsigned day :5;
|
||||
|
322
include/apple2_filetype.h
Normal file
322
include/apple2_filetype.h
Normal file
@ -0,0 +1,322 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* apple2_filetype.h */
|
||||
/* */
|
||||
/* Apple ][ file type definitions */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2017 Bill Chatfield, <bill_chatfield@yahoo.com> */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
/* warranty. In no event will the authors be held liable for any damages */
|
||||
/* arising from the use of this software. */
|
||||
/* */
|
||||
/* Permission is granted to anyone to use this software for any purpose, */
|
||||
/* including commercial applications, and to alter it and redistribute it */
|
||||
/* freely, subject to the following restrictions: */
|
||||
/* */
|
||||
/* 1. The origin of this software must not be misrepresented; you must not */
|
||||
/* claim that you wrote the original software. If you use this software */
|
||||
/* in a product, an acknowledgment in the product documentation would be */
|
||||
/* appreciated but is not required. */
|
||||
/* 2. Altered source versions must be plainly marked as such, and must not */
|
||||
/* be misrepresented as being the original software. */
|
||||
/* 3. This notice may not be removed or altered from any source */
|
||||
/* distribution. */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
#ifndef _APPLE2_FILETYPE_H
|
||||
#define _APPLE2_FILETYPE_H
|
||||
|
||||
|
||||
|
||||
/* Check for errors */
|
||||
#if !defined(__APPLE2__)
|
||||
# error This module may only be used when compiling for the Apple ][!
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Data */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
/* ProDOS general file types */
|
||||
#define PRODOS_T_UNK 0x00 /* Unknown */
|
||||
#define PRODOS_T_BAD 0x01 /* Bad blocks */
|
||||
#define PRODOS_T_PCD 0x02 /* Pascal code */
|
||||
#define PRODOS_T_PTX 0x03 /* Pascal text */
|
||||
#define PRODOS_T_TXT 0x04 /* ASCII text */
|
||||
#define PRODOS_T_PDA 0x05 /* Pascal data */
|
||||
#define PRODOS_T_BIN 0x06 /* Binary */
|
||||
#define PRODOS_T_FNT 0x07 /* Apple III font */
|
||||
#define PRODOS_T_FOT 0x08 /* Hi-res, dbl hi-res graphics */
|
||||
#define PRODOS_T_BA3 0x09 /* Apple III BASIC program */
|
||||
#define PRODOS_T_DA3 0x09 /* Apple III BASIC data */
|
||||
#define PRODOS_T_WPF 0x0A /* Generic word processing */
|
||||
#define PRODOS_T_SOS 0x0B /* SOS system */
|
||||
#define PRODOS_T_DIR 0x0F /* ProDOS directory */
|
||||
|
||||
/* ProDOS productivity file types */
|
||||
#define PRODOS_T_RPD 0x10 /* RPS data */
|
||||
#define PRODOS_T_RPI 0x11 /* RPS index */
|
||||
#define PRODOS_T_AFD 0x12 /* AppleFile discard */
|
||||
#define PRODOS_T_AFM 0x13 /* AppleFile model */
|
||||
#define PRODOS_T_AFR 0x14 /* AppleFile report */
|
||||
#define PRODOS_T_SCL 0x15 /* Screen library */
|
||||
#define PRODOS_T_PFS 0x16 /* PFS document */
|
||||
#define PRODOS_T_ADB 0x19 /* AppleWorks database */
|
||||
#define PRODOS_T_AWP 0x1A /* AppleWorks word processing */
|
||||
#define PRODOS_T_ASP 0x1B /* AppleWorks spreadsheet */
|
||||
|
||||
/* ProDOS code file types */
|
||||
#define PRODOS_T_TDM 0x20 /* Desktop Manager */
|
||||
#define PRODOS_T_IPS 0x21 /* Instant Pascal source */
|
||||
#define PRODOS_T_UPV 0x22 /* USCD Pascal volume */
|
||||
#define PRODOS_T_3SD 0x29 /* SOS directory */
|
||||
#define PRODOS_T_8SC 0x2A /* Source code */
|
||||
#define PRODOS_T_8OB 0x2B /* Object code */
|
||||
#define PRODOS_T_8IC 0x2C /* Interpreted code */
|
||||
#define PRODOS_T_8LD 0x2D /* Language data */
|
||||
#define PRODOS_T_P8C 0x2E /* ProDOS 8 code module */
|
||||
|
||||
/* ProDOS miscellaneous file types */
|
||||
#define PRODOS_T_OCR 0x41 /* Optical char recognition */
|
||||
#define PRODOS_T_FTD 0x42 /* File type definitions */
|
||||
|
||||
/* ProDOS Apple IIgs general file types */
|
||||
#define PRODOS_T_GWP 0x50 /* Apple IIgs word processing */
|
||||
#define PRODOS_T_GSS 0x51 /* Apple IIgs spreadsheet */
|
||||
#define PRODOS_T_GDB 0x52 /* Apple IIgs database */
|
||||
#define PRODOS_T_DRW 0x53 /* Object oriented graphics */
|
||||
#define PRODOS_T_GDP 0x54 /* Apple IIgs desktop publish */
|
||||
#define PRODOS_T_HMD 0x55 /* HyperMedia */
|
||||
#define PRODOS_T_EDU 0x56 /* Educational program data */
|
||||
#define PRODOS_T_STN 0x57 /* Stationary */
|
||||
#define PRODOS_T_HLP 0x58 /* Help */
|
||||
#define PRODOS_T_COM 0x59 /* Communications */
|
||||
#define PRODOS_T_CFG 0x5A /* Configuration */
|
||||
#define PRODOS_T_ANM 0x5B /* Animation */
|
||||
#define PRODOS_T_MUM 0x5C /* Multimedia */
|
||||
#define PRODOS_T_ENT 0x5D /* Entertainment */
|
||||
#define PRODOS_T_DVU 0x5E /* Development utility */
|
||||
|
||||
/* ProDOS PC Transporter file types */
|
||||
#define PRODOS_T_PRE 0x60 /* PC pre-boot */
|
||||
#define PRODOS_T_BIO 0x6B /* PC BIOS */
|
||||
#define PRODOS_T_NCF 0x66 /* ProDOS File Nav command file */
|
||||
#define PRODOS_T_DVR 0x6D /* PC driver */
|
||||
#define PRODOS_T_PRE2 0x6E /* PC pre-boot */
|
||||
#define PRODOS_T_HDV 0x6F /* PC hard disk image */
|
||||
|
||||
/* ProDOS Kreative Software file types */
|
||||
#define PRODOS_T_SN2 0x70 /* Sabine's Notebook 2.0 */
|
||||
#define PRODOS_T_KMT 0x71
|
||||
#define PRODOS_T_DSR 0x72
|
||||
#define PRODOS_T_BAN 0x73
|
||||
#define PRODOS_T_CG7 0x74
|
||||
#define PRODOS_T_TNJ 0x75
|
||||
#define PRODOS_T_SA7 0x76
|
||||
#define PRODOS_T_KES 0x77
|
||||
#define PRODOS_T_JAP 0x78
|
||||
#define PRODOS_T_CSL 0x79
|
||||
#define PRODOS_T_TME 0x7A
|
||||
#define PRODOS_T_TLB 0x7B
|
||||
#define PRODOS_T_MR7 0x7C
|
||||
#define PRODOS_T_MLR 0x7D /* Mika City */
|
||||
#define PRODOS_T_MMM 0x7E
|
||||
#define PRODOS_T_JCP 0x7F
|
||||
|
||||
/* ProDOS GEOS file types */
|
||||
#define PRODOS_T_GES 0x80 /* GEOS system file */
|
||||
#define PRODOS_T_GEA 0x81 /* GEOS desk accessory */
|
||||
#define PRODOS_T_GEO 0x82 /* GEOS application */
|
||||
#define PRODOS_T_GED 0x83 /* GEOS document */
|
||||
#define PRODOS_T_GEF 0x84 /* GEOS font */
|
||||
#define PRODOS_T_GEP 0x85 /* GEOS printer driver */
|
||||
#define PRODOS_T_GEI 0x86 /* GEOS input driver */
|
||||
#define PRODOS_T_GEX 0x87 /* GEOS auxiliary driver */
|
||||
#define PRODOS_T_GEV 0x89 /* GEOS swap file */
|
||||
#define PRODOS_T_GEC 0x8B /* GEOS clock driver */
|
||||
#define PRODOS_T_GEK 0x8C /* GEOS interface card driver */
|
||||
#define PRODOS_T_GEW 0x8D /* GEOS formatting data */
|
||||
|
||||
/* ProDOS Apple IIgs BASIC file types */
|
||||
#define PRODOS_T_WP 0xA0 /* WordPerfect */
|
||||
#define PRODOS_T_GSB 0xAB /* Apple IIgs BASIC program */
|
||||
#define PRODOS_T_TDF 0xAB /* Apple IIgs BASIC TDF */
|
||||
#define PRODOS_T_BDF 0xAB /* Apple IIgs BASIC data */
|
||||
|
||||
/* ProDOS Apple IIgs system file types */
|
||||
#define PRODOS_T_SRC 0xB0 /* Apple IIgs source code */
|
||||
#define PRODOS_T_OBJ 0xB1 /* Apple IIgs object code */
|
||||
#define PRODOS_T_LIB 0xB2 /* Apple IIgs library */
|
||||
#define PRODOS_T_S16 0xB3 /* Apple IIgs application pgm */
|
||||
#define PRODOS_T_RTL 0xB4 /* Apple IIgs runtime library */
|
||||
#define PRODOS_T_EXE 0xB5 /* Apple IIgs shell script */
|
||||
#define PRODOS_T_PIF 0xB6 /* Apple IIgs permanent init */
|
||||
#define PRODOS_T_TIF 0xB7 /* Apple IIgs temporary init */
|
||||
#define PRODOS_T_NDA 0xB8 /* Apple IIgs new desk accesry */
|
||||
#define PRODOS_T_CDA 0xB9 /* Apple IIgs classic desk aces */
|
||||
#define PRODOS_T_TOL 0xBA /* Apple IIgs tool */
|
||||
#define PRODOS_T_DRV 0xBB /* Apple IIgs device driver */
|
||||
#define PRODOS_T_LDF 0xBC /* Apple IIgs generic load file */
|
||||
#define PRODOS_T_FST 0xBD /* Apple IIgs file sys translat */
|
||||
#define PRODOS_T_DOC 0xBF /* Apple IIgs document */
|
||||
|
||||
/* ProDOS graphics file types */
|
||||
#define PRODOS_T_PNT 0xC0 /* Apple IIgs packed sup hi-res */
|
||||
#define PRODOS_T_PIC 0xC1 /* Apple IIgs super hi-res */
|
||||
#define PRODOS_T_ANI 0xC2 /* PaintWorks animation */
|
||||
#define PRODOS_T_PAL 0xC3 /* PaintWorks palette */
|
||||
#define PRODOS_T_OOG 0xC5 /* Object-oriented graphics */
|
||||
#define PRODOS_T_SCR 0xC6 /* Script */
|
||||
#define PRODOS_T_CDV 0xC7 /* Apple IIgs control panel */
|
||||
#define PRODOS_T_FON 0xC8 /* Apple IIgs font */
|
||||
#define PRODOS_T_FND 0xC9 /* Apple IIgs Finder data */
|
||||
#define PRODOS_T_ICN 0xCA /* Apple IIgs icon */
|
||||
|
||||
/* ProDOS audio file types */
|
||||
#define PRODOS_T_MUS 0xD5 /* Music */
|
||||
#define PRODOS_T_INS 0xD6 /* Instrument */
|
||||
#define PRODOS_T_MID 0xD7 /* MIDI */
|
||||
#define PRODOS_T_SND 0xD8 /* Apple IIgs audio */
|
||||
#define PRODOS_T_DBM 0xDB /* DB master document */
|
||||
|
||||
/* ProDOS miscellaneous file types */
|
||||
#define PRODOS_T_LBR 0xE0 /* Archive */
|
||||
#define PRODOS_T_ATK 0xE2 /* AppleTalk data */
|
||||
#define PRODOS_T_R16 0xEE /* EDASM 816 relocatable code */
|
||||
#define PRODOS_T_PAR 0xEF /* Pascal area */
|
||||
|
||||
/* ProDOS system file types */
|
||||
#define PRODOS_T_CMD 0xF0 /* ProDOS command file */
|
||||
#define PRODOS_T_OVL 0xF1 /* User defined 1 */
|
||||
#define PRODOS_T_UD2 0xF2 /* User defined 2 */
|
||||
#define PRODOS_T_UD3 0xF3 /* User defined 3 */
|
||||
#define PRODOS_T_UD4 0xF4 /* User defined 4 */
|
||||
#define PRODOS_T_BAT 0xF5 /* User defined 5 */
|
||||
#define PRODOS_T_UD6 0xF6 /* User defined 6 */
|
||||
#define PRODOS_T_UD7 0xF7 /* User defined 7 */
|
||||
#define PRODOS_T_PRG 0xF8 /* User defined 8 */
|
||||
#define PRODOS_T_P16 0xF9 /* ProDOS-16 system file */
|
||||
#define PRODOS_T_INT 0xFA /* Integer BASIC program */
|
||||
#define PRODOS_T_IVR 0xFB /* Integer BASIC variables */
|
||||
#define PRODOS_T_BAS 0xFC /* Applesoft BASIC program */
|
||||
#define PRODOS_T_VAR 0xFD /* Applesoft BASIC variables */
|
||||
#define PRODOS_T_REL 0xFE /* EDASM relocatable code */
|
||||
#define PRODOS_T_SYS 0xFF /* ProDOS-8 system file */
|
||||
|
||||
/* The auxiliary type of a text file specifies its record length.
|
||||
** A record length of 0 indicates a sequential text file, which is
|
||||
** equivalent to text files of other operating systems like MacOS
|
||||
** or Windows, except that lines are delimited by carriage returns
|
||||
** only. An auxiliary type value greater than 0 for a text file,
|
||||
** which is the record length, indicates a random access text file
|
||||
** with fixed-length lines.
|
||||
*/
|
||||
#define PRODOS_AUX_T_TXT_SEQ 0x0000 /* Sequential text */
|
||||
|
||||
/* 8IC auxiliary types */
|
||||
#define PRODOS_AUX_T_8IC_APEX_PGM 0x8003 /* Apex program */
|
||||
|
||||
/* GWP auxiliary types */
|
||||
#define PRODOS_AUX_T_GWP_TEACH 0x5445 /* Teach */
|
||||
#define PRODOS_AUX_T_GWP_DELUXEWRITE 0x8001 /* DeluxeWrite */
|
||||
#define PRODOS_AUX_T_GWP_APPLEWORKS_GS 0x8010 /* AppleWorks GS */
|
||||
|
||||
/* GSS auxiliary types */
|
||||
#define PRODOS_AUX_T_GSS_APPLEWORKS_GS 0x8010 /* AppleWorks GS */
|
||||
|
||||
/* GDB auxiliary types */
|
||||
#define PRODOS_AUX_T_GDB_APPLEWORKS_GS 0x8010 /* AppleWorks GS DB */
|
||||
#define PRODOS_AUX_T_GDB_AWGS_TMPL 0x8011 /* AWGS template */
|
||||
#define PRODOS_AUX_T_GDB_GSAS 0x8013
|
||||
|
||||
/* DRW auxiliary types */
|
||||
#define PRODOS_AUX_T_DRW_OO_GRAPHICS 0x8013 /* AWGS O-O graphics */
|
||||
|
||||
/* GDP auxiliary types */
|
||||
#define PRODOS_AUX_T_GDP_GRAPHICWRITER 0x8002 /* A2gs GraphicWriter */
|
||||
#define PRODOS_AUX_T_GDP_APPLEWORKS_GS 0x8010 /* A2gs AWGS */
|
||||
|
||||
/* HMD auxiliary types */
|
||||
#define PRODOS_AUX_T_HMD_HYPERCARD_GS 0x0001 /* HyperCard GS */
|
||||
#define PRODOS_AUX_T_HMD_TUTOR_TECH 0x8001 /* Tutor-Tech */
|
||||
#define PRODOS_AUX_T_HMD_HYPERSTUDIO 0x8002 /* HyperStudio */
|
||||
#define PRODOS_AUX_T_HMD_NEXUS 0x8003 /* Nexus */
|
||||
|
||||
/* COM auxiliary types */
|
||||
#define PRODOS_AUX_T_COM_APPLEWORKS_GS 0x8003 /* AppleWorks GS */
|
||||
|
||||
/* MLR auxiliary types */
|
||||
#define PRODOS_AUX_T_MLR_SCRIPT 0x005C /* Mika City script */
|
||||
#define PRODOS_AUX_T_MLR_COLOR_TABLE 0xC7AB /* Mika City color table */
|
||||
#define PRODOS_AUX_T_MLR_CHARACTER_DEF 0xCDEF /* Mika City character def */
|
||||
|
||||
/* LDF auxiliary types */
|
||||
#define PRODOS_AUX_T_LDF_NIFTY_LIST_MOD 0x4001 /* Nifty list module */
|
||||
#define PRODOS_AUX_T_LDF_SUPER_INFO_MOD 0x4002 /* Super info module */
|
||||
#define PRODOS_AUX_T_LDF_TWILIGHT_MOD 0x4004 /* Twilight module */
|
||||
#define PRODOS_AUX_T_LDF_MARINETTI_LLM 0x4004 /* Marinetti link layer mod */
|
||||
|
||||
/* PNT auxiliary types */
|
||||
#define PRODOS_AUX_T_PNT_PK_SUPER_HIRES 0x0001 /* Packed super hi-res */
|
||||
#define PRODOS_AUX_T_PNT_APPLE_PREF 0x0002 /* Apple preferred format */
|
||||
#define PRODOS_AUX_T_PNT_PK_QUICKDRAWII 0x0003 /* Packed QuickDraw II */
|
||||
|
||||
/* PIC auxiliary types */
|
||||
#define PRODOS_AUX_T_PIC_QUICKDRAW 0x0001 /* QuickDraw image */
|
||||
#define PRODOS_AUX_T_PIC_SHIRES_3200 0x0002 /* Super hi-res 3200 */
|
||||
|
||||
/* FON auxiliary types */
|
||||
#define PRODOS_AUX_T_FON_QUICKDRAW_BIT 0x0000 /* QuickDraw bitmap font */
|
||||
#define PRODOS_AUX_T_FON_POINTLESS_TT 0x0001 /* Pointless TrueType font */
|
||||
|
||||
/* SND auxiliary types */
|
||||
#define PRODOS_AUX_T_SND_AIFF 0x0000 /* AIFF */
|
||||
#define PRODOS_AUX_T_SND_AIFF_C 0x0001 /* AIFF-C */
|
||||
#define PRODOS_AUX_T_SND_ASIF_INSTR 0x0002 /* ASIF instrument */
|
||||
#define PRODOS_AUX_T_SND_SOUND_RSRC 0x0003 /* Sound resource */
|
||||
#define PRODOS_AUX_T_SND_MIDI_SYNTH_WAV 0x0004 /* MIDI synth wave */
|
||||
#define PRODOS_AUX_T_SND_HYPERSTUDIO 0x8001 /* HyperStudio sound */
|
||||
|
||||
/* LBR auxiliary types */
|
||||
#define PRODOS_AUX_T_LBR_ALU 0x0000 /* ALU */
|
||||
#define PRODOS_AUX_T_LBR_APPLE_SINGLE 0x0001 /* AppleSingle */
|
||||
#define PRODOS_AUX_T_LBR_APPLEDBL_HDR 0x0002 /* AppleDouble header */
|
||||
#define PRODOS_AUX_T_LBR_APPLEDBL_DATA 0x0003 /* AppleDouble data */
|
||||
#define PRODOS_AUX_T_LBR_BINARY_II 0x8000 /* Binary II */
|
||||
#define PRODOS_AUX_T_LBR_APPLELINK_ACU 0x8001 /* AppleLink ACU */
|
||||
#define PRODOS_AUX_T_LBR_SHRINKIT 0x8002 /* ShrinkIt */
|
||||
|
||||
/* LBR auxiliary types */
|
||||
#define PRODOS_AUX_T_ATK_EASYMNT_ALIAS 0x0000 /* EasyMount alias */
|
||||
|
||||
/* BAS auxiliary types */
|
||||
#define PRODOS_AUX_T_BAS_PGM_LOAD_ADDR 0x0801 /* Applesoft pgm load addr */
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Variables */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
/* The file stream implementation and the POSIX I/O functions will use the
|
||||
** following variables to determine the file type and auxiliary type to use.
|
||||
** This applies specifically to the fopen and open functions.
|
||||
*/
|
||||
extern unsigned char _filetype; /* Default: PRODOS_T_BIN */
|
||||
extern unsigned int _auxtype; /* Default: 0 */
|
||||
|
||||
/* End of apple2_filetype.h */
|
||||
#endif
|
@ -149,6 +149,16 @@
|
||||
#define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE
|
||||
#define TGI_COLOR_GRAY3 COLOR_GRAY3
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x01
|
||||
#define JOY_DOWN_MASK 0x02
|
||||
#define JOY_LEFT_MASK 0x04
|
||||
#define JOY_RIGHT_MASK 0x08
|
||||
#define JOY_BTN_1_MASK 0x10
|
||||
|
||||
#define JOY_FIRE_MASK JOY_BTN_1_MASK
|
||||
#define JOY_FIRE(v) ((v) & JOY_FIRE_MASK)
|
||||
|
||||
/* color register functions */
|
||||
extern void __fastcall__ _setcolor (unsigned char color_reg, unsigned char hue, unsigned char luminace);
|
||||
extern void __fastcall__ _setcolor_low (unsigned char color_reg, unsigned char color_value);
|
||||
@ -346,4 +356,4 @@ struct __iocb {
|
||||
#define IOCB_FORMAT 0xFE /* format */
|
||||
|
||||
/* End of atari.h */
|
||||
#endif /* #ifndef _ATARI_H */
|
||||
#endif
|
||||
|
@ -87,6 +87,13 @@ extern void atr5200std_joy[]; /* referred to by joy_static_stddrv[] */
|
||||
#define COLOR_LIGHTBLUE _gtia_mkcolor(HUE_BLUE,6)
|
||||
#define COLOR_GRAY3 _gtia_mkcolor(HUE_GREY,5)
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x01
|
||||
#define JOY_DOWN_MASK 0x02
|
||||
#define JOY_LEFT_MASK 0x04
|
||||
#define JOY_RIGHT_MASK 0x08
|
||||
#define JOY_BTN_1_MASK 0x10
|
||||
|
||||
/* get_tv return values */
|
||||
#define AT_NTSC 0
|
||||
#define AT_PAL 1
|
||||
@ -104,4 +111,4 @@ extern void atr5200std_joy[]; /* referred to by joy_static_stddrv[] */
|
||||
#define ANTIC (*(struct __antic*)0xD400)
|
||||
|
||||
/* End of atari5200.h */
|
||||
#endif /* #ifndef _ATARI5200_H */
|
||||
#endif
|
||||
|
@ -113,6 +113,15 @@
|
||||
|
||||
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x10
|
||||
#define JOY_DOWN_MASK 0x08
|
||||
#define JOY_LEFT_MASK 0x01
|
||||
#define JOY_RIGHT_MASK 0x02
|
||||
#define JOY_BTN_1_MASK 0x20
|
||||
|
||||
|
||||
|
||||
/* No support for dynamically loadable drivers */
|
||||
#define DYN_DRV 0
|
||||
|
||||
|
@ -91,6 +91,13 @@
|
||||
#define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE
|
||||
#define TGI_COLOR_GRAY3 COLOR_GRAY3
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x01
|
||||
#define JOY_DOWN_MASK 0x02
|
||||
#define JOY_LEFT_MASK 0x04
|
||||
#define JOY_RIGHT_MASK 0x08
|
||||
#define JOY_BTN_1_MASK 0x10
|
||||
|
||||
/* Video mode defines */
|
||||
#define VIDEOMODE_40x25 0x00
|
||||
#define VIDEOMODE_80x25 0x80
|
||||
|
@ -99,6 +99,13 @@
|
||||
#define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE
|
||||
#define TGI_COLOR_GRAY3 COLOR_GRAY3
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x01
|
||||
#define JOY_DOWN_MASK 0x02
|
||||
#define JOY_LEFT_MASK 0x04
|
||||
#define JOY_RIGHT_MASK 0x08
|
||||
#define JOY_BTN_1_MASK 0x10
|
||||
|
||||
/* Define hardware */
|
||||
#include <_vic2.h>
|
||||
#define VIC (*(struct __vic2*)0xD000)
|
||||
|
@ -75,6 +75,11 @@
|
||||
|
||||
|
||||
|
||||
#define JOY_FIRE_MASK JOY_BTN_1_MASK
|
||||
#define JOY_FIRE(v) ((v) & JOY_FIRE_MASK)
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Variables */
|
||||
/*****************************************************************************/
|
||||
@ -153,7 +158,17 @@ struct cbm_dirent {
|
||||
unsigned char get_tv (void);
|
||||
/* Return the video mode the machine is using. */
|
||||
|
||||
#define KBREPEAT_CURSOR 0x00
|
||||
#define KBREPEAT_NONE 0x40
|
||||
#define KBREPEAT_ALL 0x80
|
||||
|
||||
unsigned char __fastcall__ kbrepeat (unsigned char mode);
|
||||
/* Changes which keys have automatic repeat. */
|
||||
|
||||
#if !defined(__CBM610__) && !defined(__PET__)
|
||||
void waitvsync (void);
|
||||
/* Wait for the start of the next frame */
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
/* CBM kernal functions */
|
||||
|
@ -112,6 +112,17 @@
|
||||
#define COLOR_LIGHTBLUE (BCOLOR_LIGHTBLUE | CATTR_LUMA7)
|
||||
#define COLOR_GRAY3 (BCOLOR_WHITE | CATTR_LUMA5)
|
||||
|
||||
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x01
|
||||
#define JOY_DOWN_MASK 0x02
|
||||
#define JOY_LEFT_MASK 0x04
|
||||
#define JOY_RIGHT_MASK 0x08
|
||||
#define JOY_BTN_1_MASK 0x80
|
||||
|
||||
|
||||
|
||||
/* Define hardware */
|
||||
#include <_ted.h>
|
||||
#define TED (*(struct __ted*)0xFF00)
|
||||
|
@ -92,6 +92,13 @@
|
||||
#define COLOR_LIGHTBLUE 0x0E
|
||||
#define COLOR_GRAY3 0x0F
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x01
|
||||
#define JOY_DOWN_MASK 0x02
|
||||
#define JOY_LEFT_MASK 0x04
|
||||
#define JOY_RIGHT_MASK 0x08
|
||||
#define JOY_BTN_1_MASK 0x10
|
||||
|
||||
/* Define hardware */
|
||||
#include <_vic2.h>
|
||||
#define VIC (*(struct __vic2*)0xD800)
|
||||
|
@ -63,12 +63,16 @@
|
||||
# include <apple2enh.h>
|
||||
#elif defined(__APPLE2__)
|
||||
# include <apple2.h>
|
||||
#elif defined(__ATARI5200__)
|
||||
# include <atari5200.h>
|
||||
#elif defined(__ATARI__)
|
||||
# include <atari.h>
|
||||
#elif defined(__ATMOS__)
|
||||
# include <atmos.h>
|
||||
#elif defined(__CBM__)
|
||||
# include <cbm.h>
|
||||
#elif defined(__CREATIVISION__)
|
||||
# include <creativision.h>
|
||||
#elif defined(__GAMATE__)
|
||||
# include <gamate.h>
|
||||
#elif defined(__GEOS__)
|
||||
@ -225,6 +229,3 @@ void __fastcall__ cputhex16 (unsigned val);
|
||||
|
||||
/* End of conio.h */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
@ -40,6 +40,14 @@
|
||||
#define CH_LLCORNER 37
|
||||
#define CH_LRCORNER 38
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x10
|
||||
#define JOY_DOWN_MASK 0x04
|
||||
#define JOY_LEFT_MASK 0x20
|
||||
#define JOY_RIGHT_MASK 0x08
|
||||
#define JOY_BTN_1_MASK 0x01
|
||||
#define JOY_BTN_2_MASK 0x02
|
||||
|
||||
/* no support for dynamically loadable drivers */
|
||||
#define DYN_DRV 0
|
||||
|
||||
|
@ -89,9 +89,9 @@ unsigned char __fastcall__ toascii (unsigned char c);
|
||||
** #undef'ing the macroes.
|
||||
** Please note that the following macroes do NOT handle EOF correctly, as
|
||||
** stated in the manual. If you need correct behaviour for EOF, don't
|
||||
** use -Os, or #undefine the following macroes.
|
||||
** use --eagerly-inline-funcs, or #undefine the following macroes.
|
||||
*/
|
||||
#ifdef __OPT_s__
|
||||
#ifdef __EAGERLY_INLINE_FUNCS__
|
||||
|
||||
#define isalnum(c) (__AX__ = (c), \
|
||||
__asm__ ("tay"), \
|
||||
|
@ -52,6 +52,7 @@ typedef struct {
|
||||
/* Driver header */
|
||||
char id[3]; /* Contains 0x65, 0x6d, 0x64 ("emd") */
|
||||
unsigned char version; /* Interface version */
|
||||
void* libreference; /* Library reference */
|
||||
|
||||
/* Jump vectors. Note that these are not C callable */
|
||||
void* install; /* INSTALL routine */
|
||||
@ -74,6 +75,3 @@ extern em_drv_header* em_drv; /* Pointer to driver */
|
||||
|
||||
/* End of em-kernel.h */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
@ -80,17 +80,6 @@
|
||||
bit 3:
|
||||
*/
|
||||
|
||||
#define JOY_DATA 0x4400
|
||||
|
||||
#define JOY_DATA_UP 0x01
|
||||
#define JOY_DATA_DOWN 0x02
|
||||
#define JOY_DATA_LEFT 0x04
|
||||
#define JOY_DATA_RIGHT 0x08
|
||||
#define JOY_DATA_FIRE_A 0x10
|
||||
#define JOY_DATA_FIRE_B 0x20
|
||||
#define JOY_DATA_START 0x40
|
||||
#define JOY_DATA_SELECT 0x80
|
||||
|
||||
/* LCD
|
||||
|
||||
resolution 160x152 in 4 greys/greens
|
||||
@ -181,15 +170,31 @@
|
||||
/* No support for dynamically loadable drivers */
|
||||
#define DYN_DRV 0
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x01
|
||||
#define JOY_DOWN_MASK 0x02
|
||||
#define JOY_LEFT_MASK 0x04
|
||||
#define JOY_RIGHT_MASK 0x08
|
||||
#define JOY_BTN_1_MASK 0x10
|
||||
#define JOY_BTN_2_MASK 0x20
|
||||
#define JOY_BTN_3_MASK 0x40
|
||||
#define JOY_BTN_4_MASK 0x80
|
||||
|
||||
#define JOY_BTN_A_MASK JOY_BTN_1_MASK
|
||||
#define JOY_BTN_B_MASk JOY_BTN_2_MASK
|
||||
#define JOY_START_MASK JOY_BTN_3_MASK
|
||||
#define JOY_SELECT_MASK JOY_BTN_4_MASK
|
||||
|
||||
#define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK)
|
||||
#define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK)
|
||||
#define JOY_START(v) ((v) & JOY_START_MASK)
|
||||
#define JOY_SELECT(v) ((v) & JOY_SELECT_MASK)
|
||||
|
||||
/* The addresses of the static drivers */
|
||||
extern void gamate_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
|
||||
|
||||
#define JOY_FIRE_B 5
|
||||
#define JOY_START 6
|
||||
#define JOY_SELECT 7
|
||||
|
||||
void waitvblank (void);
|
||||
/* Wait for the vertical blanking */
|
||||
void waitvsync (void);
|
||||
/* Wait for start of next frame */
|
||||
|
||||
/* NOTE: all Gamate are "NTSC" */
|
||||
#define get_tv() TV_NTSC
|
||||
|
@ -133,6 +133,12 @@
|
||||
#define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE
|
||||
#define TGI_COLOR_GRAY3 COLOR_GRAY3
|
||||
|
||||
#define JOY_UP_MASK 0x01
|
||||
#define JOY_DOWN_MASK 0x02
|
||||
#define JOY_LEFT_MASK 0x04
|
||||
#define JOY_RIGHT_MASK 0x08
|
||||
#define JOY_BTN_1_MASK 0x10
|
||||
|
||||
|
||||
/* End of geos.h */
|
||||
#endif
|
||||
|
@ -52,27 +52,18 @@
|
||||
#define JOY_ERR_NO_DEVICE 4 /* Device (hardware) not found */
|
||||
|
||||
/* Argument for the joy_read function */
|
||||
#define JOY_1 0
|
||||
#define JOY_2 1
|
||||
|
||||
/* The following codes are *indices* into the joy_masks array */
|
||||
#define JOY_UP 0
|
||||
#define JOY_DOWN 1
|
||||
#define JOY_LEFT 2
|
||||
#define JOY_RIGHT 3
|
||||
#define JOY_FIRE 4
|
||||
#define JOY_FIRE2 5 /* Second fire button if available */
|
||||
|
||||
/* Array of masks used to check the return value of joy_read for a state */
|
||||
extern const unsigned char joy_masks[8];
|
||||
#define JOY_1 0
|
||||
#define JOY_2 1
|
||||
|
||||
/* Macros that evaluate the return code of joy_read */
|
||||
#define JOY_BTN_UP(v) ((v) & joy_masks[JOY_UP])
|
||||
#define JOY_BTN_DOWN(v) ((v) & joy_masks[JOY_DOWN])
|
||||
#define JOY_BTN_LEFT(v) ((v) & joy_masks[JOY_LEFT])
|
||||
#define JOY_BTN_RIGHT(v) ((v) & joy_masks[JOY_RIGHT])
|
||||
#define JOY_BTN_FIRE(v) ((v) & joy_masks[JOY_FIRE])
|
||||
#define JOY_BTN_FIRE2(v) ((v) & joy_masks[JOY_FIRE2])
|
||||
#define JOY_UP(v) ((v) & JOY_UP_MASK)
|
||||
#define JOY_DOWN(v) ((v) & JOY_DOWN_MASK)
|
||||
#define JOY_LEFT(v) ((v) & JOY_LEFT_MASK)
|
||||
#define JOY_RIGHT(v) ((v) & JOY_RIGHT_MASK)
|
||||
#define JOY_BTN_1(v) ((v) & JOY_BTN_1_MASK) /* Universally available */
|
||||
#define JOY_BTN_2(v) ((v) & JOY_BTN_2_MASK) /* Second button if available */
|
||||
#define JOY_BTN_3(v) ((v) & JOY_BTN_3_MASK) /* Third button if available */
|
||||
#define JOY_BTN_4(v) ((v) & JOY_BTN_4_MASK) /* Fourth button if available */
|
||||
|
||||
/* The name of the standard joystick driver for a platform */
|
||||
extern const char joy_stddrv[];
|
||||
|
@ -52,9 +52,7 @@ typedef struct {
|
||||
/* Driver header */
|
||||
char id[3]; /* Contains 0x6a, 0x6f, 0x79 ("joy") */
|
||||
unsigned char version; /* Interface version */
|
||||
|
||||
/* Bitmasks for the joystick states. See joystick.h for indices */
|
||||
unsigned char masks[8];
|
||||
void* libreference; /* Library reference */
|
||||
|
||||
/* Jump vectors. Note that these are not C callable */
|
||||
void* install; /* INSTALL routine */
|
||||
@ -85,6 +83,3 @@ void joy_clear_ptr (void);
|
||||
|
||||
/* End of joy-kernel.h */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
@ -87,6 +87,20 @@
|
||||
#define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE
|
||||
#define TGI_COLOR_WHITE COLOR_WHITE
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x80
|
||||
#define JOY_DOWN_MASK 0x40
|
||||
#define JOY_LEFT_MASK 0x20
|
||||
#define JOY_RIGHT_MASK 0x10
|
||||
#define JOY_BTN_1_MASK 0x01
|
||||
#define JOY_BTN_2_MASK 0x02
|
||||
|
||||
#define JOY_BTN_A_MASK JOY_BTN_1_MASK
|
||||
#define JOY_BTN_B_MASK JOY_BTN_2_MASK
|
||||
|
||||
#define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK)
|
||||
#define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK)
|
||||
|
||||
/* No support for dynamically loadable drivers */
|
||||
#define DYN_DRV 0
|
||||
|
||||
|
43
include/lz4.h
Normal file
43
include/lz4.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* lz4.h */
|
||||
/* */
|
||||
/* Decompression routine for the 'lz4' format */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2017 Mega Cat Studios */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
/* warranty. In no event will the authors be held liable for any damages */
|
||||
/* arising from the use of this software. */
|
||||
/* */
|
||||
/* Permission is granted to anyone to use this software for any purpose, */
|
||||
/* including commercial applications, and to alter it and redistribute it */
|
||||
/* freely, subject to the following restrictions: */
|
||||
/* */
|
||||
/* 1. The origin of this software must not be misrepresented; you must not */
|
||||
/* claim that you wrote the original software. If you use this software */
|
||||
/* in a product, an acknowledgment in the product documentation would be */
|
||||
/* appreciated but is not required. */
|
||||
/* 2. Altered source versions must be plainly marked as such, and must not */
|
||||
/* be misrepresented as being the original software. */
|
||||
/* 3. This notice may not be removed or altered from any source */
|
||||
/* distribution. */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
#ifndef _LZ4_H
|
||||
#define _LZ4_H
|
||||
|
||||
void __fastcall__ decompress_lz4 (const unsigned char* src, unsigned char* const dst,
|
||||
const unsigned short uncompressed_size);
|
||||
/* Decompresses the source buffer into the destination buffer.
|
||||
** The size of the decompressed data must be known in advance, LZ4
|
||||
** does not include any terminator in-stream.
|
||||
*/
|
||||
|
||||
/* end of lz4.h */
|
||||
#endif
|
@ -82,6 +82,26 @@
|
||||
#define COLOR_LIGHTBLUE 0x0E
|
||||
#define COLOR_GRAY3 0x0F
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x10
|
||||
#define JOY_DOWN_MASK 0x20
|
||||
#define JOY_LEFT_MASK 0x40
|
||||
#define JOY_RIGHT_MASK 0x80
|
||||
#define JOY_BTN_1_MASK 0x01
|
||||
#define JOY_BTN_2_MASK 0x02
|
||||
#define JOY_BTN_3_MASK 0x04
|
||||
#define JOY_BTN_4_MASK 0x08
|
||||
|
||||
#define JOY_BTN_A_MASK JOY_BTN_1_MASK
|
||||
#define JOY_BTN_B_MASK JOY_BTN_2_MASK
|
||||
#define JOY_SELECT_MASK JOY_BTN_3_MASK
|
||||
#define JOY_START_MASK JOY_BTN_4_MASK
|
||||
|
||||
#define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK)
|
||||
#define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK)
|
||||
#define JOY_SELECT(v) ((v) & JOY_SELECT_MASK)
|
||||
#define JOY_START(v) ((v) & JOY_START_MASK)
|
||||
|
||||
/* Return codes of get_tv */
|
||||
#define TV_NTSC 0
|
||||
#define TV_PAL 1
|
||||
@ -90,16 +110,6 @@
|
||||
/* No support for dynamically loadable drivers */
|
||||
#define DYN_DRV 0
|
||||
|
||||
/* The joystick keys - all keys are supported */
|
||||
#define KEY_A 0x01
|
||||
#define KEY_B 0x02
|
||||
#define KEY_SELECT 0x04
|
||||
#define KEY_START 0x08
|
||||
#define KEY_UP 0x10
|
||||
#define KEY_DOWN 0x20
|
||||
#define KEY_LEFT 0x40
|
||||
#define KEY_RIGHT 0x80
|
||||
|
||||
/* Define hardware */
|
||||
|
||||
/* Picture Processing Unit */
|
||||
@ -163,8 +173,8 @@ extern void nes_64_56_2_tgi[]; /* Referred to by tgi_static_stddrv[] */
|
||||
|
||||
|
||||
|
||||
void waitvblank (void);
|
||||
/* Wait for the vertical blanking */
|
||||
void waitvsync (void);
|
||||
/* Wait for start of the next frame */
|
||||
|
||||
unsigned char get_tv (void);
|
||||
/* Return the video mode the machine is using. */
|
||||
|
@ -1,47 +1,47 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* osic1p.h */
|
||||
/* */
|
||||
/* Challenger 1P system specific definitions */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2015 Stephan Muehlstrasser */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
/* warranty. In no event will the authors be held liable for any damages */
|
||||
/* arising from the use of this software. */
|
||||
/* */
|
||||
/* Permission is granted to anyone to use this software for any purpose, */
|
||||
/* including commercial applications, and to alter it and redistribute it */
|
||||
/* freely, subject to the following restrictions: */
|
||||
/* */
|
||||
/* 1. The origin of this software must not be misrepresented; you must not */
|
||||
/* claim that you wrote the original software. If you use this software */
|
||||
/* in a product, an acknowledgment in the product documentation would be */
|
||||
/* appreciated but is not required. */
|
||||
/* 2. Altered source versions must be plainly marked as such, and must not */
|
||||
/* be misrepresented as being the original software. */
|
||||
/* 3. This notice may not be removed or altered from any source */
|
||||
/* distribution. */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef _OSIC1P_H
|
||||
#define _OSIC1P_H
|
||||
|
||||
/* Check for errors */
|
||||
#if !defined(__OSIC1P__)
|
||||
# error "This module may only be used when compiling for the Challenger 1P!"
|
||||
#endif
|
||||
|
||||
/* The following #defines will cause the matching functions calls in conio.h
|
||||
** to be overlaid by macros with the same names, saving the function call
|
||||
** overhead.
|
||||
*/
|
||||
#define _textcolor(color) COLOR_WHITE
|
||||
#define _bgcolor(color) COLOR_BLACK
|
||||
#define _bordercolor(color) COLOR_BLACK
|
||||
|
||||
#endif
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* osic1p.h */
|
||||
/* */
|
||||
/* Challenger 1P system specific definitions */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2015 Stephan Muehlstrasser */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
/* warranty. In no event will the authors be held liable for any damages */
|
||||
/* arising from the use of this software. */
|
||||
/* */
|
||||
/* Permission is granted to anyone to use this software for any purpose, */
|
||||
/* including commercial applications, and to alter it and redistribute it */
|
||||
/* freely, subject to the following restrictions: */
|
||||
/* */
|
||||
/* 1. The origin of this software must not be misrepresented; you must not */
|
||||
/* claim that you wrote the original software. If you use this software */
|
||||
/* in a product, an acknowledgment in the product documentation would be */
|
||||
/* appreciated but is not required. */
|
||||
/* 2. Altered source versions must be plainly marked as such, and must not */
|
||||
/* be misrepresented as being the original software. */
|
||||
/* 3. This notice may not be removed or altered from any source */
|
||||
/* distribution. */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef _OSIC1P_H
|
||||
#define _OSIC1P_H
|
||||
|
||||
/* Check for errors */
|
||||
#if !defined(__OSIC1P__)
|
||||
# error "This module may only be used when compiling for the Challenger 1P!"
|
||||
#endif
|
||||
|
||||
/* The following #defines will cause the matching functions calls in conio.h
|
||||
** to be overlaid by macros with the same names, saving the function call
|
||||
** overhead.
|
||||
*/
|
||||
#define _textcolor(color) COLOR_WHITE
|
||||
#define _bgcolor(color) COLOR_BLACK
|
||||
#define _bordercolor(color) COLOR_BLACK
|
||||
|
||||
#endif
|
||||
|
@ -73,18 +73,34 @@
|
||||
#define TV_PAL 1
|
||||
#define TV_OTHER 2
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x10
|
||||
#define JOY_DOWN_MASK 0x40
|
||||
#define JOY_LEFT_MASK 0x80
|
||||
#define JOY_RIGHT_MASK 0x20
|
||||
#define JOY_BTN_1_MASK 0x01
|
||||
#define JOY_BTN_2_MASK 0x02
|
||||
#define JOY_BTN_3_MASK 0x04
|
||||
#define JOY_BTN_4_MASK 0x08
|
||||
|
||||
#define JOY_BTN_I_MASK JOY_BTN_1_MASK
|
||||
#define JOY_BTN_II_MASK JOY_BTN_2_MASK
|
||||
#define JOY_SELECT_MASK JOY_BTN_3_MASK
|
||||
#define JOY_RUN_MASK JOY_BTN_4_MASK
|
||||
|
||||
#define JOY_BTN_I(v) ((v) & JOY_BTN_I_MASK)
|
||||
#define JOY_BTN_II(v) ((v) & JOY_BTN_II_MASK)
|
||||
#define JOY_SELECT(v) ((v) & JOY_SELECT_MASK)
|
||||
#define JOY_RUN(v) ((v) & JOY_RUN_MASK)
|
||||
|
||||
/* No support for dynamically loadable drivers */
|
||||
#define DYN_DRV 0
|
||||
#define DYN_DRV 0
|
||||
|
||||
/* The addresses of the static drivers */
|
||||
extern void pce_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
|
||||
|
||||
#define JOY_FIRE_B 5
|
||||
#define JOY_SELECT 6
|
||||
#define JOY_RUN 7
|
||||
|
||||
void waitvblank (void);
|
||||
/* Wait for the vertical blanking */
|
||||
void waitvsync (void);
|
||||
/* Wait for start of the next frame */
|
||||
|
||||
/* NOTE: all PCE are NTSC */
|
||||
#define get_tv() TV_NTSC
|
||||
|
@ -55,6 +55,13 @@
|
||||
#define COLOR_BLACK 0x00
|
||||
#define COLOR_WHITE 0x01
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x01
|
||||
#define JOY_DOWN_MASK 0x02
|
||||
#define JOY_LEFT_MASK 0x04
|
||||
#define JOY_RIGHT_MASK 0x08
|
||||
#define JOY_BTN_1_MASK 0x10
|
||||
|
||||
/* Define hardware */
|
||||
#include <_pia.h>
|
||||
#define PIA1 (*(struct __pia*)0xE810)
|
||||
|
@ -77,6 +77,15 @@
|
||||
|
||||
|
||||
|
||||
/* Masks for joy_read */
|
||||
#define JOY_UP_MASK 0x01
|
||||
#define JOY_DOWN_MASK 0x02
|
||||
#define JOY_LEFT_MASK 0x04
|
||||
#define JOY_RIGHT_MASK 0x08
|
||||
#define JOY_BTN_1_MASK 0x10
|
||||
|
||||
|
||||
|
||||
/* Define hardware */
|
||||
#include <_vic.h>
|
||||
#define VIC (*(struct __vic*)0x9000)
|
||||
|
344
include/zlib.h
344
include/zlib.h
@ -1,172 +1,172 @@
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* zlib.h */
|
||||
/* */
|
||||
/* Decompression routines for the 'deflate' format */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2000-2015 Piotr Fusik <fox@scene.pl> */
|
||||
/* */
|
||||
/* This file is based on the zlib.h from 'zlib' general purpose compression */
|
||||
/* library, version 1.1.3, (C) 1995-1998 Jean-loup Gailly and Mark Adler. */
|
||||
/* */
|
||||
/* Jean-loup Gailly Mark Adler */
|
||||
/* jloup@gzip.org madler@alumni.caltech.edu */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
/* warranty. In no event will the authors be held liable for any damages */
|
||||
/* arising from the use of this software. */
|
||||
/* */
|
||||
/* Permission is granted to anyone to use this software for any purpose, */
|
||||
/* including commercial applications, and to alter it and redistribute it */
|
||||
/* freely, subject to the following restrictions: */
|
||||
/* */
|
||||
/* 1. The origin of this software must not be misrepresented; you must not */
|
||||
/* claim that you wrote the original software. If you use this software */
|
||||
/* in a product, an acknowledgment in the product documentation would be */
|
||||
/* appreciated but is not required. */
|
||||
/* 2. Altered source versions must be plainly marked as such, and must not */
|
||||
/* be misrepresented as being the original software. */
|
||||
/* 3. This notice may not be removed or altered from any source */
|
||||
/* distribution. */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
#ifndef _ZLIB_H
|
||||
#define _ZLIB_H
|
||||
|
||||
#define Z_OK 0
|
||||
#define Z_DATA_ERROR (-3)
|
||||
/* Return codes for uncompress() */
|
||||
|
||||
#define Z_DEFLATED 8
|
||||
/* The deflate compression method (the only one supported) */
|
||||
|
||||
#define Z_NULL 0
|
||||
|
||||
|
||||
unsigned __fastcall__ inflatemem (char* dest, const char* source);
|
||||
/*
|
||||
Decompresses the source buffer into the destination buffer.
|
||||
Returns the size of the uncompressed data (number of bytes written starting
|
||||
from dest).
|
||||
|
||||
This function expects data in the DEFLATE format, described in RFC
|
||||
(Request for Comments) 1951 in the file
|
||||
ftp://ds.internic.net/rfc/rfc1951.txt.
|
||||
|
||||
This function does not exist in the original zlib. Its implementation
|
||||
using original zlib might be following:
|
||||
|
||||
unsigned inflatemem (char* dest, const char* source)
|
||||
{
|
||||
z_stream stream;
|
||||
|
||||
stream.next_in = (Bytef*) source;
|
||||
stream.avail_in = 65535;
|
||||
|
||||
stream.next_out = dest;
|
||||
stream.avail_out = 65535;
|
||||
|
||||
stream.zalloc = (alloc_func) 0;
|
||||
stream.zfree = (free_func) 0;
|
||||
|
||||
inflateInit2(&stream, -MAX_WBITS);
|
||||
inflate(&stream, Z_FINISH);
|
||||
inflateEnd(&stream);
|
||||
|
||||
return stream.total_out;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
int __fastcall__ uncompress (char* dest, unsigned* destLen,
|
||||
const char* source, unsigned sourceLen);
|
||||
/*
|
||||
Original zlib description:
|
||||
|
||||
Decompresses the source buffer into the destination buffer. sourceLen is
|
||||
the byte length of the source buffer. Upon entry, destLen is the total
|
||||
size of the destination buffer, which must be large enough to hold the
|
||||
entire uncompressed data. (The size of the uncompressed data must have
|
||||
been saved previously by the compressor and transmitted to the decompressor
|
||||
by some mechanism outside the scope of this compression library.)
|
||||
Upon exit, destLen is the actual size of the compressed buffer.
|
||||
This function can be used to decompress a whole file at once if the
|
||||
input file is mmap'ed.
|
||||
|
||||
uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
|
||||
enough memory, Z_BUF_ERROR if there was not enough room in the output
|
||||
buffer, or Z_DATA_ERROR if the input data was corrupted.
|
||||
|
||||
Implementation notes:
|
||||
|
||||
This function expects data in the ZLIB format, described in RFC 1950
|
||||
in the file ftp://ds.internic.net/rfc/rfc1950.txt. The ZLIB format is
|
||||
essentially the DEFLATE format plus a very small header and Adler-32
|
||||
checksum.
|
||||
|
||||
Z_MEM_ERROR and Z_BUF_ERROR are never returned in this implementation.
|
||||
*/
|
||||
|
||||
|
||||
unsigned long __fastcall__ adler32 (unsigned long adler, const char* buf,
|
||||
unsigned len);
|
||||
|
||||
/*
|
||||
Original zlib description:
|
||||
|
||||
Update a running Adler-32 checksum with the bytes buf[0..len-1] and
|
||||
return the updated checksum. If buf is NULL, this function returns
|
||||
the required initial value for the checksum.
|
||||
An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
|
||||
much faster. Usage example:
|
||||
|
||||
unsigned long adler = adler32(0L, Z_NULL, 0);
|
||||
|
||||
while (read_buffer(buffer, length) != EOF) {
|
||||
adler = adler32(adler, buffer, length);
|
||||
}
|
||||
if (adler != original_adler) error();
|
||||
|
||||
Implementation notes:
|
||||
|
||||
This function isn't actually much faster than crc32(), but it is smaller
|
||||
and does not use any lookup tables.
|
||||
*/
|
||||
|
||||
|
||||
unsigned long __fastcall__ crc32 (unsigned long crc, const char* buf,
|
||||
unsigned len);
|
||||
/*
|
||||
Original zlib description:
|
||||
|
||||
Update a running crc with the bytes buf[0..len-1] and return the updated
|
||||
crc. If buf is NULL, this function returns the required initial value
|
||||
for the crc. Pre- and post-conditioning (one's complement) is performed
|
||||
within this function so it shouldn't be done by the application.
|
||||
Usage example:
|
||||
|
||||
unsigned long crc = crc32(0L, Z_NULL, 0);
|
||||
|
||||
while (read_buffer(buffer, length) != EOF) {
|
||||
crc = crc32(crc, buffer, length);
|
||||
}
|
||||
if (crc != original_crc) error();
|
||||
|
||||
Implementation notes:
|
||||
|
||||
This function uses statically allocated 1 KB lookup table. The table is
|
||||
initialised before it is used for the first time (that is, if buffer is
|
||||
NULL or length is zero, then the lookup table isn't initialised).
|
||||
*/
|
||||
|
||||
|
||||
/* end of zlib.h */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* */
|
||||
/* zlib.h */
|
||||
/* */
|
||||
/* Decompression routines for the 'deflate' format */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2000-2015 Piotr Fusik <fox@scene.pl> */
|
||||
/* */
|
||||
/* This file is based on the zlib.h from 'zlib' general purpose compression */
|
||||
/* library, version 1.1.3, (C) 1995-1998 Jean-loup Gailly and Mark Adler. */
|
||||
/* */
|
||||
/* Jean-loup Gailly Mark Adler */
|
||||
/* jloup@gzip.org madler@alumni.caltech.edu */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
/* warranty. In no event will the authors be held liable for any damages */
|
||||
/* arising from the use of this software. */
|
||||
/* */
|
||||
/* Permission is granted to anyone to use this software for any purpose, */
|
||||
/* including commercial applications, and to alter it and redistribute it */
|
||||
/* freely, subject to the following restrictions: */
|
||||
/* */
|
||||
/* 1. The origin of this software must not be misrepresented; you must not */
|
||||
/* claim that you wrote the original software. If you use this software */
|
||||
/* in a product, an acknowledgment in the product documentation would be */
|
||||
/* appreciated but is not required. */
|
||||
/* 2. Altered source versions must be plainly marked as such, and must not */
|
||||
/* be misrepresented as being the original software. */
|
||||
/* 3. This notice may not be removed or altered from any source */
|
||||
/* distribution. */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
#ifndef _ZLIB_H
|
||||
#define _ZLIB_H
|
||||
|
||||
#define Z_OK 0
|
||||
#define Z_DATA_ERROR (-3)
|
||||
/* Return codes for uncompress() */
|
||||
|
||||
#define Z_DEFLATED 8
|
||||
/* The deflate compression method (the only one supported) */
|
||||
|
||||
#define Z_NULL 0
|
||||
|
||||
|
||||
unsigned __fastcall__ inflatemem (char* dest, const char* source);
|
||||
/*
|
||||
Decompresses the source buffer into the destination buffer.
|
||||
Returns the size of the uncompressed data (number of bytes written starting
|
||||
from dest).
|
||||
|
||||
This function expects data in the DEFLATE format, described in RFC
|
||||
(Request for Comments) 1951 in the file
|
||||
ftp://ds.internic.net/rfc/rfc1951.txt.
|
||||
|
||||
This function does not exist in the original zlib. Its implementation
|
||||
using original zlib might be following:
|
||||
|
||||
unsigned inflatemem (char* dest, const char* source)
|
||||
{
|
||||
z_stream stream;
|
||||
|
||||
stream.next_in = (Bytef*) source;
|
||||
stream.avail_in = 65535;
|
||||
|
||||
stream.next_out = dest;
|
||||
stream.avail_out = 65535;
|
||||
|
||||
stream.zalloc = (alloc_func) 0;
|
||||
stream.zfree = (free_func) 0;
|
||||
|
||||
inflateInit2(&stream, -MAX_WBITS);
|
||||
inflate(&stream, Z_FINISH);
|
||||
inflateEnd(&stream);
|
||||
|
||||
return stream.total_out;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
int __fastcall__ uncompress (char* dest, unsigned* destLen,
|
||||
const char* source, unsigned sourceLen);
|
||||
/*
|
||||
Original zlib description:
|
||||
|
||||
Decompresses the source buffer into the destination buffer. sourceLen is
|
||||
the byte length of the source buffer. Upon entry, destLen is the total
|
||||
size of the destination buffer, which must be large enough to hold the
|
||||
entire uncompressed data. (The size of the uncompressed data must have
|
||||
been saved previously by the compressor and transmitted to the decompressor
|
||||
by some mechanism outside the scope of this compression library.)
|
||||
Upon exit, destLen is the actual size of the compressed buffer.
|
||||
This function can be used to decompress a whole file at once if the
|
||||
input file is mmap'ed.
|
||||
|
||||
uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
|
||||
enough memory, Z_BUF_ERROR if there was not enough room in the output
|
||||
buffer, or Z_DATA_ERROR if the input data was corrupted.
|
||||
|
||||
Implementation notes:
|
||||
|
||||
This function expects data in the ZLIB format, described in RFC 1950
|
||||
in the file ftp://ds.internic.net/rfc/rfc1950.txt. The ZLIB format is
|
||||
essentially the DEFLATE format plus a very small header and Adler-32
|
||||
checksum.
|
||||
|
||||
Z_MEM_ERROR and Z_BUF_ERROR are never returned in this implementation.
|
||||
*/
|
||||
|
||||
|
||||
unsigned long __fastcall__ adler32 (unsigned long adler, const char* buf,
|
||||
unsigned len);
|
||||
|
||||
/*
|
||||
Original zlib description:
|
||||
|
||||
Update a running Adler-32 checksum with the bytes buf[0..len-1] and
|
||||
return the updated checksum. If buf is NULL, this function returns
|
||||
the required initial value for the checksum.
|
||||
An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
|
||||
much faster. Usage example:
|
||||
|
||||
unsigned long adler = adler32(0L, Z_NULL, 0);
|
||||
|
||||
while (read_buffer(buffer, length) != EOF) {
|
||||
adler = adler32(adler, buffer, length);
|
||||
}
|
||||
if (adler != original_adler) error();
|
||||
|
||||
Implementation notes:
|
||||
|
||||
This function isn't actually much faster than crc32(), but it is smaller
|
||||
and does not use any lookup tables.
|
||||
*/
|
||||
|
||||
|
||||
unsigned long __fastcall__ crc32 (unsigned long crc, const char* buf,
|
||||
unsigned len);
|
||||
/*
|
||||
Original zlib description:
|
||||
|
||||
Update a running crc with the bytes buf[0..len-1] and return the updated
|
||||
crc. If buf is NULL, this function returns the required initial value
|
||||
for the crc. Pre- and post-conditioning (one's complement) is performed
|
||||
within this function so it shouldn't be done by the application.
|
||||
Usage example:
|
||||
|
||||
unsigned long crc = crc32(0L, Z_NULL, 0);
|
||||
|
||||
while (read_buffer(buffer, length) != EOF) {
|
||||
crc = crc32(crc, buffer, length);
|
||||
}
|
||||
if (crc != original_crc) error();
|
||||
|
||||
Implementation notes:
|
||||
|
||||
This function uses statically allocated 1 KB lookup table. The table is
|
||||
initialised before it is used for the first time (that is, if buffer is
|
||||
NULL or length is zero, then the lookup table isn't initialised).
|
||||
*/
|
||||
|
||||
|
||||
/* end of zlib.h */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
ifneq ($(shell echo),)
|
||||
CMD_EXE = 1
|
||||
endif
|
||||
@ -15,24 +14,24 @@ CBMS = c128 \
|
||||
GEOS = geos-apple \
|
||||
geos-cbm
|
||||
|
||||
TARGETS = apple2 \
|
||||
apple2enh \
|
||||
atari \
|
||||
atarixl \
|
||||
atari2600 \
|
||||
atari5200 \
|
||||
atmos \
|
||||
TARGETS = apple2 \
|
||||
apple2enh \
|
||||
atari \
|
||||
atarixl \
|
||||
atari2600 \
|
||||
atari5200 \
|
||||
atmos \
|
||||
creativision \
|
||||
$(CBMS) \
|
||||
$(GEOS) \
|
||||
gamate \
|
||||
lynx \
|
||||
nes \
|
||||
osic1p \
|
||||
pce \
|
||||
sim6502 \
|
||||
sim65c02 \
|
||||
supervision\
|
||||
$(CBMS) \
|
||||
$(GEOS) \
|
||||
gamate \
|
||||
lynx \
|
||||
nes \
|
||||
osic1p \
|
||||
pce \
|
||||
sim6502 \
|
||||
sim65c02 \
|
||||
supervision \
|
||||
telestrat
|
||||
|
||||
DRVTYPES = emd \
|
||||
@ -41,13 +40,13 @@ DRVTYPES = emd \
|
||||
ser \
|
||||
tgi
|
||||
|
||||
OUTPUTDIRS := lib \
|
||||
asminc \
|
||||
cfg \
|
||||
include \
|
||||
$(subst ../,,$(filter-out $(wildcard ../include/*.*),$(wildcard ../include/*)))\
|
||||
$(subst ../,,$(wildcard ../target/*/drv/*))\
|
||||
$(subst ../,,$(wildcard ../target/*/util))\
|
||||
OUTPUTDIRS := lib \
|
||||
asminc \
|
||||
cfg \
|
||||
include \
|
||||
$(subst ../,,$(filter-out $(wildcard ../include/*.*),$(wildcard ../include/*))) \
|
||||
$(subst ../,,$(wildcard ../target/*/drv/*)) \
|
||||
$(subst ../,,$(wildcard ../target/*/util))
|
||||
|
||||
.PHONY: all mostlyclean clean install zip lib $(TARGETS)
|
||||
|
||||
@ -73,7 +72,7 @@ endif
|
||||
|
||||
ifndef TARGET
|
||||
|
||||
datadir = $(prefix)/share/cc65
|
||||
datadir = $(PREFIX)/share/cc65
|
||||
|
||||
all lib: $(TARGETS)
|
||||
|
||||
@ -93,7 +92,7 @@ INSTALL = install
|
||||
|
||||
define INSTALL_recipe
|
||||
|
||||
$(if $(prefix),,$(error variable `prefix' must be set))
|
||||
$(if $(PREFIX),,$(error variable `PREFIX' must be set))
|
||||
$(INSTALL) -d $(DESTDIR)$(datadir)/$(dir)
|
||||
$(INSTALL) -m0644 ../$(dir)/*.* $(DESTDIR)$(datadir)/$(dir)
|
||||
|
||||
@ -197,6 +196,7 @@ DEPS = $(OBJS:.o=.d)
|
||||
EXTRA_SRCPAT = $(SRCDIR)/extra/%.s
|
||||
EXTRA_OBJPAT = ../lib/$(TARGET)-%.o
|
||||
EXTRA_OBJS := $(patsubst $(EXTRA_SRCPAT),$(EXTRA_OBJPAT),$(wildcard $(SRCDIR)/extra/*.s))
|
||||
DEPS += $(EXTRA_OBJS:../lib/%.o=../libwrk/$(TARGET)/%.d)
|
||||
|
||||
ZPOBJ = ../libwrk/$(TARGET)/zeropage.o
|
||||
ifeq ($(TARGET),$(filter $(TARGET),$(EXTZP)))
|
||||
@ -280,9 +280,9 @@ endef # COMPILE_recipe
|
||||
../libwrk/$(TARGET)/%.o: %.c | ../libwrk/$(TARGET)
|
||||
$(COMPILE_recipe)
|
||||
|
||||
$(EXTRA_OBJPAT): $(EXTRA_SRCPAT) | ../lib
|
||||
$(EXTRA_OBJPAT): $(EXTRA_SRCPAT) | ../libwrk/$(TARGET) ../lib
|
||||
@echo $(TARGET) - $(<F)
|
||||
@$(CA65) -t $(TARGET) $(CA65FLAGS) -o $@ $<
|
||||
@$(CA65) -t $(TARGET) $(CA65FLAGS) --create-dep $(@:../lib/%.o=../libwrk/$(TARGET)/%.d) -o $@ $<
|
||||
|
||||
../lib/$(TARGET).lib: $(OBJS) | ../lib
|
||||
$(AR65) a $@ $?
|
||||
|
@ -46,17 +46,6 @@ PREAD := $FB1E ; Read paddle in X, return AD conv. value in Y
|
||||
|
||||
.addr $0000
|
||||
|
||||
; Button state masks (8 values)
|
||||
|
||||
.byte $10
|
||||
.byte $20
|
||||
.byte $04
|
||||
.byte $08
|
||||
.byte $40
|
||||
.byte $80
|
||||
.byte $00 ; Future expansion
|
||||
.byte $00 ; Future expansion
|
||||
|
||||
; Jump table
|
||||
|
||||
.addr INSTALL
|
||||
@ -119,7 +108,7 @@ READJOY:
|
||||
lda BUTN0-1,x ; Check button (1, 3)
|
||||
asl
|
||||
tya
|
||||
ror ; FIRE DOWN !UP RIGHT !LEFT 0 0 0
|
||||
ror ; BTN DOWN !UP RIGHT !LEFT 0 0 0
|
||||
|
||||
; Read secondary button
|
||||
tay
|
||||
@ -130,10 +119,10 @@ READJOY:
|
||||
lda BUTN0-1,x ; Check button (2, 0)
|
||||
asl
|
||||
tya
|
||||
ror ; FIRE2 FIRE DOWN !UP RIGHT !LEFT 0 0
|
||||
ror ; BTN2 BTN DOWN !UP RIGHT !LEFT 0 0
|
||||
|
||||
; Finalize
|
||||
eor #%00010100 ; FIRE2 FIRE DOWN UP RIGHT LEFT 0 0
|
||||
eor #%00010100 ; BTN2 BTN DOWN UP RIGHT LEFT 0 0
|
||||
ldx #$00
|
||||
bit $C080 ; Switch in LC bank 2 for R/O
|
||||
rts
|
||||
|
@ -6,9 +6,9 @@
|
||||
;
|
||||
|
||||
.include "atari.inc"
|
||||
.export _cgetc,setcursor
|
||||
.export _cgetc
|
||||
.import setcursor
|
||||
.import KEYBDV_handler
|
||||
.import cursor,mul40
|
||||
|
||||
_cgetc:
|
||||
jsr setcursor
|
||||
@ -29,43 +29,3 @@ _cgetc:
|
||||
pha
|
||||
rts
|
||||
.endif
|
||||
|
||||
.proc setcursor
|
||||
|
||||
ldy #0
|
||||
lda OLDCHR
|
||||
sta (OLDADR),y
|
||||
|
||||
lda ROWCRS
|
||||
jsr mul40
|
||||
clc
|
||||
adc SAVMSC ; add start of screen memory
|
||||
sta OLDADR
|
||||
txa
|
||||
adc SAVMSC+1
|
||||
sta OLDADR+1
|
||||
lda COLCRS
|
||||
adc OLDADR
|
||||
sta OLDADR
|
||||
bcc nc
|
||||
inc OLDADR+1
|
||||
nc: lda (OLDADR),y
|
||||
sta OLDCHR
|
||||
|
||||
ldx cursor ; current cursor setting as requested by the user
|
||||
beq off
|
||||
ldx #0
|
||||
beq cont
|
||||
|
||||
off: inx
|
||||
cont: stx CRSINH ; update system variable
|
||||
|
||||
beq turnon
|
||||
and #$7f ; clear high bit / inverse flag
|
||||
finish: sta (OLDADR),y ; update on-screen display
|
||||
rts
|
||||
|
||||
turnon: ora #$80 ; set high bit / inverse flag
|
||||
bne finish
|
||||
|
||||
.endproc
|
||||
|
@ -35,17 +35,6 @@
|
||||
|
||||
.addr $0000
|
||||
|
||||
; Button state masks (8 values)
|
||||
|
||||
.byte $02 ; JOY_UP
|
||||
.byte $04 ; JOY_DOWN
|
||||
.byte $08 ; JOY_LEFT
|
||||
.byte $10 ; JOY_RIGHT
|
||||
.byte $01 ; JOY_FIRE
|
||||
.byte $00 ; JOY_FIRE2 not available
|
||||
.byte $00 ; Future expansion
|
||||
.byte $00 ; Future expansion
|
||||
|
||||
; Jump table.
|
||||
|
||||
.addr INSTALL
|
||||
@ -115,10 +104,12 @@ READJOY:
|
||||
|
||||
; Read joystick
|
||||
|
||||
lda PORTA ; get position
|
||||
and #%00001111
|
||||
lda STRIG0 ; get button
|
||||
asl a
|
||||
ora TRIG0 ; add button information
|
||||
eor #%00011111
|
||||
asl a
|
||||
asl a
|
||||
asl a
|
||||
ora PORTA ; add position information
|
||||
eor #$1F
|
||||
ldx #0 ; fix X
|
||||
rts
|
||||
|
@ -34,17 +34,6 @@
|
||||
|
||||
.addr $0000
|
||||
|
||||
; Button state masks (8 values)
|
||||
|
||||
.byte $01 ; JOY_UP
|
||||
.byte $02 ; JOY_DOWN
|
||||
.byte $04 ; JOY_LEFT
|
||||
.byte $08 ; JOY_RIGHT
|
||||
.byte $10 ; JOY_FIRE
|
||||
.byte $00 ; JOY_FIRE2 not available
|
||||
.byte $00 ; Future expansion
|
||||
.byte $00 ; Future expansion
|
||||
|
||||
; Jump table.
|
||||
|
||||
.addr INSTALL
|
||||
|
48
libsrc/atari/setcursor.s
Normal file
48
libsrc/atari/setcursor.s
Normal file
@ -0,0 +1,48 @@
|
||||
;
|
||||
; Christian Groessler, November-2002
|
||||
;
|
||||
; cursor handling, internal function
|
||||
|
||||
.include "atari.inc"
|
||||
.import cursor,mul40
|
||||
.export setcursor
|
||||
|
||||
.proc setcursor
|
||||
|
||||
ldy #0
|
||||
lda OLDCHR
|
||||
sta (OLDADR),y
|
||||
|
||||
lda ROWCRS
|
||||
jsr mul40
|
||||
clc
|
||||
adc SAVMSC ; add start of screen memory
|
||||
sta OLDADR
|
||||
txa
|
||||
adc SAVMSC+1
|
||||
sta OLDADR+1
|
||||
lda COLCRS
|
||||
adc OLDADR
|
||||
sta OLDADR
|
||||
bcc nc
|
||||
inc OLDADR+1
|
||||
nc: lda (OLDADR),y
|
||||
sta OLDCHR
|
||||
|
||||
ldx cursor ; current cursor setting as requested by the user
|
||||
beq off
|
||||
ldx #0
|
||||
beq cont
|
||||
|
||||
off: inx
|
||||
cont: stx CRSINH ; update system variable
|
||||
|
||||
beq turnon
|
||||
and #$7f ; clear high bit / inverse flag
|
||||
finish: sta (OLDADR),y ; update on-screen display
|
||||
rts
|
||||
|
||||
turnon: ora #$80 ; set high bit / inverse flag
|
||||
bne finish
|
||||
|
||||
.endproc
|
@ -27,17 +27,6 @@
|
||||
|
||||
.addr $0000
|
||||
|
||||
; Button state masks (8 values)
|
||||
|
||||
.byte $01 ; JOY_UP
|
||||
.byte $02 ; JOY_DOWN
|
||||
.byte $04 ; JOY_LEFT
|
||||
.byte $08 ; JOY_RIGHT
|
||||
.byte $10 ; JOY_FIRE
|
||||
.byte $20 ; JOY_FIRE2
|
||||
.byte $00 ; Future expansion
|
||||
.byte $00 ; Future expansion
|
||||
|
||||
; Jump table.
|
||||
|
||||
.addr INSTALL
|
||||
@ -99,7 +88,7 @@ READJOY:
|
||||
lda #0 ; Initialize return value
|
||||
cmp TRIG0,y
|
||||
bne @notrg
|
||||
lda #$10 ; JOY_FIRE
|
||||
lda #$10 ; JOY_BTN
|
||||
|
||||
; Read joystick
|
||||
|
||||
|
@ -1,14 +1,18 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 2003-04-13
|
||||
; 2003-04-13, Ullrich von Bassewitz
|
||||
; 2017-06-15, Greg King
|
||||
;
|
||||
; void gotoxy (unsigned char x, unsigned char y);
|
||||
;
|
||||
|
||||
.export _gotoxy
|
||||
.export gotoxy, _gotoxy
|
||||
|
||||
.import popa
|
||||
|
||||
.include "atmos.inc"
|
||||
|
||||
gotoxy: jsr popa ; Get Y
|
||||
|
||||
.proc _gotoxy
|
||||
|
||||
sta CURS_Y ; Set Y
|
||||
@ -17,5 +21,3 @@
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
|
@ -28,17 +28,6 @@
|
||||
|
||||
.addr $0000
|
||||
|
||||
; Button state masks (8 values)
|
||||
|
||||
.byte $10 ; JOY_UP
|
||||
.byte $08 ; JOY_DOWN
|
||||
.byte $01 ; JOY_LEFT
|
||||
.byte $02 ; JOY_RIGHT
|
||||
.byte $20 ; JOY_FIRE
|
||||
.byte $00 ; Future expansion
|
||||
.byte $00 ; Future expansion
|
||||
.byte $00 ; Future expansion
|
||||
|
||||
; Jump table.
|
||||
|
||||
.addr INSTALL
|
||||
|
@ -30,17 +30,6 @@
|
||||
|
||||
.addr $0000
|
||||
|
||||
; Button state masks (8 values)
|
||||
|
||||
.byte $01 ; JOY_UP
|
||||
.byte $02 ; JOY_DOWN
|
||||
.byte $04 ; JOY_LEFT
|
||||
.byte $08 ; JOY_RIGHT
|
||||
.byte $10 ; JOY_FIRE
|
||||
.byte $00 ; JOY_FIRE2 unavailable
|
||||
.byte $00 ; Future expansion
|
||||
.byte $00 ; Future expansion
|
||||
|
||||
; Jump table.
|
||||
|
||||
.addr INSTALL
|
||||
|
@ -30,17 +30,6 @@
|
||||
|
||||
.addr $0000
|
||||
|
||||
; Button state masks (8 values)
|
||||
|
||||
.byte $01 ; JOY_UP
|
||||
.byte $02 ; JOY_DOWN
|
||||
.byte $04 ; JOY_LEFT
|
||||
.byte $08 ; JOY_RIGHT
|
||||
.byte $10 ; JOY_FIRE
|
||||
.byte $00 ; JOY_FIRE2 unavailable
|
||||
.byte $00 ; Future expansion
|
||||
.byte $00 ; Future expansion
|
||||
|
||||
; Jump table.
|
||||
|
||||
.addr INSTALL
|
||||
@ -104,7 +93,7 @@ joy1: lda #$7F
|
||||
sei
|
||||
sta CIA1_PRA
|
||||
lda CIA1_PRB
|
||||
cli
|
||||
back: cli
|
||||
and #$1F
|
||||
eor #$1F
|
||||
rts
|
||||
@ -118,9 +107,4 @@ joy2: ldx #0
|
||||
sta CIA1_DDRA
|
||||
lda CIA1_PRA
|
||||
sty CIA1_DDRA
|
||||
cli
|
||||
and #$1F
|
||||
eor #$1F
|
||||
rts
|
||||
|
||||
|
||||
jmp back
|
||||
|
14
libsrc/c128/kbrepeat.s
Normal file
14
libsrc/c128/kbrepeat.s
Normal file
@ -0,0 +1,14 @@
|
||||
;
|
||||
; unsigned char __fastcall__ kbrepeat (unsigned char mode);
|
||||
;
|
||||
|
||||
.export _kbrepeat
|
||||
|
||||
.include "c128.inc"
|
||||
|
||||
_kbrepeat:
|
||||
ldx KBDREPEAT ; get old value
|
||||
sta KBDREPEAT ; store new value
|
||||
txa ; return old value
|
||||
ldx #0
|
||||
rts
|
30
libsrc/c128/waitvsync.s
Normal file
30
libsrc/c128/waitvsync.s
Normal file
@ -0,0 +1,30 @@
|
||||
;
|
||||
; Written by Groepaz <groepaz@gmx.net>
|
||||
;
|
||||
; void waitvsync (void);
|
||||
;
|
||||
|
||||
.export _waitvsync
|
||||
|
||||
.include "c128.inc"
|
||||
|
||||
_waitvsync:
|
||||
|
||||
bit MODE
|
||||
bmi @c80
|
||||
|
||||
@l1:
|
||||
bit VIC_CTRL1
|
||||
bpl @l1
|
||||
@l2:
|
||||
bit VIC_CTRL1
|
||||
bmi @l2
|
||||
rts
|
||||
|
||||
@c80:
|
||||
;FIXME: do we have to switch banks?
|
||||
@l3:
|
||||
lda VDC_INDEX
|
||||
and #$20
|
||||
beq @l3
|
||||
rts
|
@ -1,376 +1,376 @@
|
||||
;
|
||||
; Extended memory driver for 65816 based extra RAM. Driver works without
|
||||
; problems when statically linked.
|
||||
;
|
||||
; Marco van den Heuvel, 2015-12-01
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "em-kernel.inc"
|
||||
.include "em-error.inc"
|
||||
|
||||
|
||||
.macpack generic
|
||||
.macpack module
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Header. Includes jump table
|
||||
|
||||
module_header _c64_65816_emd
|
||||
|
||||
; Driver signature
|
||||
|
||||
.byte $65, $6d, $64 ; "emd"
|
||||
.byte EMD_API_VERSION ; EM API version number
|
||||
|
||||
; Library reference
|
||||
|
||||
.addr $0000
|
||||
|
||||
; Jump table
|
||||
|
||||
.addr INSTALL
|
||||
.addr UNINSTALL
|
||||
.addr PAGECOUNT
|
||||
.addr MAP
|
||||
.addr USE
|
||||
.addr COMMIT
|
||||
.addr COPYFROM
|
||||
.addr COPYTO
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Data.
|
||||
|
||||
.bss
|
||||
isnotscpu: .res 1 ; SuperCPU not present
|
||||
curpage: .res 1 ; Current page number
|
||||
curbank: .res 1 ; Current bank number (+1)
|
||||
bankcount: .res 1 ; Number of available banks (pages = banks * 256)
|
||||
window: .res 256 ; Memory "window"
|
||||
|
||||
.code
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; INSTALL routine. Is called after the driver is loaded into memory. If
|
||||
; possible, check if the hardware is present and determine the amount of
|
||||
; memory available.
|
||||
; Must return an EM_ERR_xx code in a/x.
|
||||
;
|
||||
|
||||
INSTALL:
|
||||
sei
|
||||
clc
|
||||
sed
|
||||
lda #$99
|
||||
adc #$01 ; on 65C02, 65SC02, 65CE02, 65802 and 65816 sets the zero flag correctly
|
||||
cld
|
||||
bne @not_present
|
||||
clc
|
||||
.P816
|
||||
sep #$01 ; nop #$01 on 65C02/65SC02 and lda ($01,s),y on 65CE02
|
||||
.P02
|
||||
bcc @not_present
|
||||
lda $d0bc
|
||||
and #$80
|
||||
sta isnotscpu
|
||||
lda $07e8
|
||||
pha ; save value incase it was used somewhere else
|
||||
ldx #$ff
|
||||
@fillloop: ; fill from top (bank 255) to bottom
|
||||
txa
|
||||
pha
|
||||
.P816
|
||||
plb ; pull dbr
|
||||
.P02
|
||||
stx $07e8
|
||||
dex
|
||||
cpx #$ff
|
||||
bne @fillloop
|
||||
inx
|
||||
@compareloop: ; check from bottom to top
|
||||
txa
|
||||
pha
|
||||
.P816
|
||||
plb
|
||||
.P02
|
||||
cmp $07e8
|
||||
bne @found_pages
|
||||
.P816
|
||||
inc
|
||||
.P02
|
||||
sta $07e8
|
||||
cmp $07e8
|
||||
bne @found_pages
|
||||
inx
|
||||
bne @compareloop
|
||||
@found_pages:
|
||||
dex
|
||||
lda #$00
|
||||
pha
|
||||
.P816
|
||||
plb
|
||||
.P02
|
||||
pla
|
||||
sta $07e8
|
||||
cli
|
||||
lda isnotscpu
|
||||
bne @noextradex
|
||||
dex
|
||||
@noextradex:
|
||||
stx bankcount
|
||||
lda #<EM_ERR_OK
|
||||
ldx #>EM_ERR_OK
|
||||
rts
|
||||
@not_present:
|
||||
cli
|
||||
lda #<EM_ERR_NO_DEVICE
|
||||
ldx #>EM_ERR_NO_DEVICE
|
||||
; rts ; Run into UNINSTALL instead
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; UNINSTALL routine. Is called before the driver is removed from memory.
|
||||
; Can do cleanup or whatever. Must not return anything.
|
||||
;
|
||||
|
||||
UNINSTALL:
|
||||
rts
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; PAGECOUNT: Return the total number of available pages in a/x.
|
||||
;
|
||||
|
||||
PAGECOUNT:
|
||||
lda #$00 ; a whole bank is either usable or not
|
||||
ldx bankcount
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; MAP: Map the page in a/x into memory and return a pointer to the page in
|
||||
; a/x. The contents of the currently mapped page (if any) may be discarded
|
||||
; by the driver.
|
||||
;
|
||||
|
||||
MAP: sta curpage ; Remember the new page
|
||||
stx curbank ; Remember the new bank
|
||||
|
||||
sta ptr2+1 ; src address low
|
||||
lda #$00
|
||||
sta ptr2 ; src address high
|
||||
inx
|
||||
ldy isnotscpu ; check if not scpu
|
||||
bne @notscpu
|
||||
inx
|
||||
@notscpu:
|
||||
stx tmp2 ; src bank
|
||||
|
||||
sta tmp1 ; dst bank
|
||||
|
||||
sta ptr3+1 ; length high
|
||||
lda #$ff
|
||||
sta ptr3 ; length low
|
||||
|
||||
lda #<window
|
||||
sta ptr1 ; dst address low
|
||||
ldx #>window
|
||||
stx ptr1+1 ; dst address high
|
||||
|
||||
jsr transfer
|
||||
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; USE: Tell the driver that the window is now associated with a given page.
|
||||
|
||||
USE: sta curpage ; Remember the page
|
||||
stx curbank ; Remember the bank
|
||||
lda #<window
|
||||
ldx #>window ; Return the window
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; COMMIT: Commit changes in the memory window to extended storage.
|
||||
|
||||
COMMIT: lda curpage ; Get the current page
|
||||
sta ptr1+1 ; dst high
|
||||
ldx #$00
|
||||
stx ptr1 ; dst low
|
||||
|
||||
lda #<window
|
||||
sta ptr2 ; src low
|
||||
lda #>window
|
||||
sta ptr2+1 ; src high
|
||||
|
||||
stx ptr3+1 ; length high
|
||||
lda #$ff
|
||||
sta ptr3 ; length low
|
||||
|
||||
stx tmp2 ; src bank
|
||||
ldy curbank ; Get the current bank
|
||||
iny
|
||||
ldx isnotscpu
|
||||
bne @notascpu
|
||||
iny
|
||||
@notascpu:
|
||||
sty tmp1 ; dst bank
|
||||
|
||||
jsr transfer
|
||||
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; COPYFROM: Copy from extended into linear memory. A pointer to a structure
|
||||
; describing the request is passed in a/x.
|
||||
; The function must not return anything.
|
||||
;
|
||||
|
||||
COPYFROM:
|
||||
sta ptr4
|
||||
stx ptr4+1 ; Save the passed em_copy pointer
|
||||
|
||||
ldy #EM_COPY::COUNT+1 ; start at the end of the struct
|
||||
lda (ptr4),y ; get high byte of count
|
||||
tax
|
||||
dey
|
||||
lda (ptr4),y ; get low byte of count
|
||||
bne @nodex
|
||||
dex
|
||||
@nodex:
|
||||
.P816
|
||||
dec
|
||||
.P02
|
||||
sta ptr3 ; length low
|
||||
stx ptr3+1 ; length high
|
||||
dey
|
||||
lda (ptr4),y ; get bank
|
||||
.P816
|
||||
inc
|
||||
.P02
|
||||
ldx isnotscpu
|
||||
bne @notscpu64
|
||||
.P816
|
||||
inc
|
||||
.P02
|
||||
@notscpu64:
|
||||
sta tmp2 ; src bank
|
||||
dey
|
||||
lda (ptr4),y ; get page
|
||||
sta ptr2+1 ; src high
|
||||
dey
|
||||
lda (ptr4),y ; get offset in page
|
||||
sta ptr2 ; src low
|
||||
dey
|
||||
lda (ptr4),y ; get memory buffer high
|
||||
sta ptr1+1 ; dst high
|
||||
dey
|
||||
lda (ptr4),y ; get memory buffer low
|
||||
sta ptr1 ; dst low
|
||||
lda #$00
|
||||
sta tmp1 ; dst bank
|
||||
|
||||
jsr transfer
|
||||
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; COPYTO: Copy from linear into extended memory. A pointer to a structure
|
||||
; describing the request is passed in a/x.
|
||||
; The function must not return anything.
|
||||
;
|
||||
|
||||
COPYTO: sta ptr4
|
||||
stx ptr4+1 ; Save the passed em_copy pointer
|
||||
|
||||
ldy #EM_COPY::COUNT+1 ; start at the end of the struct
|
||||
lda (ptr4),y ; get high byte of count
|
||||
tax
|
||||
dey
|
||||
lda (ptr4),y ; get low byte of count
|
||||
bne @nodex2
|
||||
dex
|
||||
@nodex2:
|
||||
.P816
|
||||
dec
|
||||
.P02
|
||||
sta ptr3 ; length low
|
||||
txa
|
||||
sta ptr3+1 ; length high
|
||||
dey
|
||||
lda (ptr4),y ; get bank
|
||||
.P816
|
||||
inc
|
||||
.P02
|
||||
ldx isnotscpu
|
||||
bne @notascpu64
|
||||
.P816
|
||||
inc
|
||||
.P02
|
||||
@notascpu64:
|
||||
sta tmp1 ; dst bank
|
||||
dey
|
||||
lda (ptr4),y ; get page
|
||||
sta ptr1+1 ; dst high
|
||||
dey
|
||||
lda (ptr4),y ; get page offset
|
||||
sta ptr1 ; dst low
|
||||
dey
|
||||
lda (ptr4),y ; get memory buffer high
|
||||
sta ptr2+1 ; src low
|
||||
dey
|
||||
lda (ptr4),y ; get memory buffer low
|
||||
sta ptr2 ; src high
|
||||
lda #$00
|
||||
sta tmp2 ; src bank
|
||||
|
||||
jsr transfer
|
||||
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Helper function for moving a block, the following is used:
|
||||
; ptr1: dst
|
||||
; ptr2: src
|
||||
; ptr3: length
|
||||
; tmp1: dst bank
|
||||
; tmp2: src bank
|
||||
|
||||
transfer:
|
||||
.P816
|
||||
.A8
|
||||
.I8
|
||||
sei
|
||||
pha
|
||||
phx
|
||||
phy
|
||||
ldx tmp1 ; load srcbank
|
||||
stx @move+1 ; store srcbank in move + 1
|
||||
ldy tmp2 ; load dstbank
|
||||
sty @move+2 ; store dstbank in move + 2
|
||||
clc ; switch to native mode
|
||||
xce
|
||||
php ; save status bits
|
||||
rep #%00110000 ; set A and index to 16bit
|
||||
.A16
|
||||
.I16
|
||||
ldy ptr1
|
||||
ldx ptr2
|
||||
lda ptr3
|
||||
@move:
|
||||
mvn 0,0
|
||||
plp ; restore status bits
|
||||
.A8
|
||||
.I8
|
||||
lda #$00
|
||||
pha
|
||||
plb ; restore dbr
|
||||
sec
|
||||
xce ; switch to emul mode
|
||||
ply
|
||||
plx
|
||||
pla
|
||||
cli
|
||||
rts
|
||||
.P02
|
||||
;
|
||||
; Extended memory driver for 65816 based extra RAM. Driver works without
|
||||
; problems when statically linked.
|
||||
;
|
||||
; Marco van den Heuvel, 2015-12-01
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "em-kernel.inc"
|
||||
.include "em-error.inc"
|
||||
|
||||
|
||||
.macpack generic
|
||||
.macpack module
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Header. Includes jump table
|
||||
|
||||
module_header _c64_65816_emd
|
||||
|
||||
; Driver signature
|
||||
|
||||
.byte $65, $6d, $64 ; "emd"
|
||||
.byte EMD_API_VERSION ; EM API version number
|
||||
|
||||
; Library reference
|
||||
|
||||
.addr $0000
|
||||
|
||||
; Jump table
|
||||
|
||||
.addr INSTALL
|
||||
.addr UNINSTALL
|
||||
.addr PAGECOUNT
|
||||
.addr MAP
|
||||
.addr USE
|
||||
.addr COMMIT
|
||||
.addr COPYFROM
|
||||
.addr COPYTO
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Data.
|
||||
|
||||
.bss
|
||||
isnotscpu: .res 1 ; SuperCPU not present
|
||||
curpage: .res 1 ; Current page number
|
||||
curbank: .res 1 ; Current bank number (+1)
|
||||
bankcount: .res 1 ; Number of available banks (pages = banks * 256)
|
||||
window: .res 256 ; Memory "window"
|
||||
|
||||
.code
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; INSTALL routine. Is called after the driver is loaded into memory. If
|
||||
; possible, check if the hardware is present and determine the amount of
|
||||
; memory available.
|
||||
; Must return an EM_ERR_xx code in a/x.
|
||||
;
|
||||
|
||||
INSTALL:
|
||||
sei
|
||||
clc
|
||||
sed
|
||||
lda #$99
|
||||
adc #$01 ; on 65C02, 65SC02, 65CE02, 65802 and 65816 sets the zero flag correctly
|
||||
cld
|
||||
bne @not_present
|
||||
clc
|
||||
.P816
|
||||
sep #$01 ; nop #$01 on 65C02/65SC02 and lda ($01,s),y on 65CE02
|
||||
.P02
|
||||
bcc @not_present
|
||||
lda $d0bc
|
||||
and #$80
|
||||
sta isnotscpu
|
||||
lda $07e8
|
||||
pha ; save value incase it was used somewhere else
|
||||
ldx #$ff
|
||||
@fillloop: ; fill from top (bank 255) to bottom
|
||||
txa
|
||||
pha
|
||||
.P816
|
||||
plb ; pull dbr
|
||||
.P02
|
||||
stx $07e8
|
||||
dex
|
||||
cpx #$ff
|
||||
bne @fillloop
|
||||
inx
|
||||
@compareloop: ; check from bottom to top
|
||||
txa
|
||||
pha
|
||||
.P816
|
||||
plb
|
||||
.P02
|
||||
cmp $07e8
|
||||
bne @found_pages
|
||||
.P816
|
||||
inc
|
||||
.P02
|
||||
sta $07e8
|
||||
cmp $07e8
|
||||
bne @found_pages
|
||||
inx
|
||||
bne @compareloop
|
||||
@found_pages:
|
||||
dex
|
||||
lda #$00
|
||||
pha
|
||||
.P816
|
||||
plb
|
||||
.P02
|
||||
pla
|
||||
sta $07e8
|
||||
cli
|
||||
lda isnotscpu
|
||||
bne @noextradex
|
||||
dex
|
||||
@noextradex:
|
||||
stx bankcount
|
||||
lda #<EM_ERR_OK
|
||||
ldx #>EM_ERR_OK
|
||||
rts
|
||||
@not_present:
|
||||
cli
|
||||
lda #<EM_ERR_NO_DEVICE
|
||||
ldx #>EM_ERR_NO_DEVICE
|
||||
; rts ; Run into UNINSTALL instead
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; UNINSTALL routine. Is called before the driver is removed from memory.
|
||||
; Can do cleanup or whatever. Must not return anything.
|
||||
;
|
||||
|
||||
UNINSTALL:
|
||||
rts
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; PAGECOUNT: Return the total number of available pages in a/x.
|
||||
;
|
||||
|
||||
PAGECOUNT:
|
||||
lda #$00 ; a whole bank is either usable or not
|
||||
ldx bankcount
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; MAP: Map the page in a/x into memory and return a pointer to the page in
|
||||
; a/x. The contents of the currently mapped page (if any) may be discarded
|
||||
; by the driver.
|
||||
;
|
||||
|
||||
MAP: sta curpage ; Remember the new page
|
||||
stx curbank ; Remember the new bank
|
||||
|
||||
sta ptr2+1 ; src address low
|
||||
lda #$00
|
||||
sta ptr2 ; src address high
|
||||
inx
|
||||
ldy isnotscpu ; check if not scpu
|
||||
bne @notscpu
|
||||
inx
|
||||
@notscpu:
|
||||
stx tmp2 ; src bank
|
||||
|
||||
sta tmp1 ; dst bank
|
||||
|
||||
sta ptr3+1 ; length high
|
||||
lda #$ff
|
||||
sta ptr3 ; length low
|
||||
|
||||
lda #<window
|
||||
sta ptr1 ; dst address low
|
||||
ldx #>window
|
||||
stx ptr1+1 ; dst address high
|
||||
|
||||
jsr transfer
|
||||
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; USE: Tell the driver that the window is now associated with a given page.
|
||||
|
||||
USE: sta curpage ; Remember the page
|
||||
stx curbank ; Remember the bank
|
||||
lda #<window
|
||||
ldx #>window ; Return the window
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; COMMIT: Commit changes in the memory window to extended storage.
|
||||
|
||||
COMMIT: lda curpage ; Get the current page
|
||||
sta ptr1+1 ; dst high
|
||||
ldx #$00
|
||||
stx ptr1 ; dst low
|
||||
|
||||
lda #<window
|
||||
sta ptr2 ; src low
|
||||
lda #>window
|
||||
sta ptr2+1 ; src high
|
||||
|
||||
stx ptr3+1 ; length high
|
||||
lda #$ff
|
||||
sta ptr3 ; length low
|
||||
|
||||
stx tmp2 ; src bank
|
||||
ldy curbank ; Get the current bank
|
||||
iny
|
||||
ldx isnotscpu
|
||||
bne @notascpu
|
||||
iny
|
||||
@notascpu:
|
||||
sty tmp1 ; dst bank
|
||||
|
||||
jsr transfer
|
||||
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; COPYFROM: Copy from extended into linear memory. A pointer to a structure
|
||||
; describing the request is passed in a/x.
|
||||
; The function must not return anything.
|
||||
;
|
||||
|
||||
COPYFROM:
|
||||
sta ptr4
|
||||
stx ptr4+1 ; Save the passed em_copy pointer
|
||||
|
||||
ldy #EM_COPY::COUNT+1 ; start at the end of the struct
|
||||
lda (ptr4),y ; get high byte of count
|
||||
tax
|
||||
dey
|
||||
lda (ptr4),y ; get low byte of count
|
||||
bne @nodex
|
||||
dex
|
||||
@nodex:
|
||||
.P816
|
||||
dec
|
||||
.P02
|
||||
sta ptr3 ; length low
|
||||
stx ptr3+1 ; length high
|
||||
dey
|
||||
lda (ptr4),y ; get bank
|
||||
.P816
|
||||
inc
|
||||
.P02
|
||||
ldx isnotscpu
|
||||
bne @notscpu64
|
||||
.P816
|
||||
inc
|
||||
.P02
|
||||
@notscpu64:
|
||||
sta tmp2 ; src bank
|
||||
dey
|
||||
lda (ptr4),y ; get page
|
||||
sta ptr2+1 ; src high
|
||||
dey
|
||||
lda (ptr4),y ; get offset in page
|
||||
sta ptr2 ; src low
|
||||
dey
|
||||
lda (ptr4),y ; get memory buffer high
|
||||
sta ptr1+1 ; dst high
|
||||
dey
|
||||
lda (ptr4),y ; get memory buffer low
|
||||
sta ptr1 ; dst low
|
||||
lda #$00
|
||||
sta tmp1 ; dst bank
|
||||
|
||||
jsr transfer
|
||||
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; COPYTO: Copy from linear into extended memory. A pointer to a structure
|
||||
; describing the request is passed in a/x.
|
||||
; The function must not return anything.
|
||||
;
|
||||
|
||||
COPYTO: sta ptr4
|
||||
stx ptr4+1 ; Save the passed em_copy pointer
|
||||
|
||||
ldy #EM_COPY::COUNT+1 ; start at the end of the struct
|
||||
lda (ptr4),y ; get high byte of count
|
||||
tax
|
||||
dey
|
||||
lda (ptr4),y ; get low byte of count
|
||||
bne @nodex2
|
||||
dex
|
||||
@nodex2:
|
||||
.P816
|
||||
dec
|
||||
.P02
|
||||
sta ptr3 ; length low
|
||||
txa
|
||||
sta ptr3+1 ; length high
|
||||
dey
|
||||
lda (ptr4),y ; get bank
|
||||
.P816
|
||||
inc
|
||||
.P02
|
||||
ldx isnotscpu
|
||||
bne @notascpu64
|
||||
.P816
|
||||
inc
|
||||
.P02
|
||||
@notascpu64:
|
||||
sta tmp1 ; dst bank
|
||||
dey
|
||||
lda (ptr4),y ; get page
|
||||
sta ptr1+1 ; dst high
|
||||
dey
|
||||
lda (ptr4),y ; get page offset
|
||||
sta ptr1 ; dst low
|
||||
dey
|
||||
lda (ptr4),y ; get memory buffer high
|
||||
sta ptr2+1 ; src low
|
||||
dey
|
||||
lda (ptr4),y ; get memory buffer low
|
||||
sta ptr2 ; src high
|
||||
lda #$00
|
||||
sta tmp2 ; src bank
|
||||
|
||||
jsr transfer
|
||||
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Helper function for moving a block, the following is used:
|
||||
; ptr1: dst
|
||||
; ptr2: src
|
||||
; ptr3: length
|
||||
; tmp1: dst bank
|
||||
; tmp2: src bank
|
||||
|
||||
transfer:
|
||||
.P816
|
||||
.A8
|
||||
.I8
|
||||
sei
|
||||
pha
|
||||
phx
|
||||
phy
|
||||
ldx tmp1 ; load srcbank
|
||||
stx @move+1 ; store srcbank in move + 1
|
||||
ldy tmp2 ; load dstbank
|
||||
sty @move+2 ; store dstbank in move + 2
|
||||
clc ; switch to native mode
|
||||
xce
|
||||
php ; save status bits
|
||||
rep #%00110000 ; set A and index to 16bit
|
||||
.A16
|
||||
.I16
|
||||
ldy ptr1
|
||||
ldx ptr2
|
||||
lda ptr3
|
||||
@move:
|
||||
mvn 0,0
|
||||
plp ; restore status bits
|
||||
.A8
|
||||
.I8
|
||||
lda #$00
|
||||
pha
|
||||
plb ; restore dbr
|
||||
sec
|
||||
xce ; switch to emul mode
|
||||
ply
|
||||
plx
|
||||
pla
|
||||
cli
|
||||
rts
|
||||
.P02
|
||||
|
@ -29,17 +29,6 @@
|
||||
|
||||
.addr $0000
|
||||
|
||||
; Button state masks (8 values)
|
||||
|
||||
.byte $01 ; JOY_UP
|
||||
.byte $02 ; JOY_DOWN
|
||||
.byte $04 ; JOY_LEFT
|
||||
.byte $08 ; JOY_RIGHT
|
||||
.byte $10 ; JOY_FIRE
|
||||
.byte $00 ; JOY_FIRE2 unavailable
|
||||
.byte $00 ; Future expansion
|
||||
.byte $00 ; Future expansion
|
||||
|
||||
; Jump table.
|
||||
|
||||
.addr INSTALL
|
||||
|
@ -30,17 +30,6 @@
|
||||
|
||||
.addr $0000
|
||||
|
||||
; Button state masks (8 values)
|
||||
|
||||
.byte $02 ; JOY_UP "8"
|
||||
.byte $10 ; JOY_DOWN "2"
|
||||
.byte $20 ; JOY_LEFT "4"
|
||||
.byte $08 ; JOY_RIGHT "6"
|
||||
.byte $04 ; JOY_FIRE "5" ENTER
|
||||
.byte $00 ; JOY_FIRE2 unavailable
|
||||
.byte $00 ; Future expansion
|
||||
.byte $00 ; Future expansion
|
||||
|
||||
; Jump table.
|
||||
|
||||
.addr INSTALL
|
||||
@ -58,6 +47,49 @@ JOY_COUNT = 1 ; Number of joysticks we support
|
||||
; ------------------------------------------------------------------------
|
||||
; Data.
|
||||
|
||||
.rodata
|
||||
|
||||
; <U>p '8' key
|
||||
; <D>own '2' key
|
||||
; <L>eft '4' key
|
||||
; <R>ight '6' key
|
||||
; <B>utton '5' or ENTER key
|
||||
|
||||
masktable:
|
||||
; Input: LDRBU
|
||||
; Output: BRLDU
|
||||
.byte %00000000 ; $00
|
||||
.byte %00000001 ; $01
|
||||
.byte %00010000 ; $02
|
||||
.byte %00010001 ; $03
|
||||
.byte %00001000 ; $04
|
||||
.byte %00001001 ; $05
|
||||
.byte %00011000 ; $06
|
||||
.byte %00011001 ; $07
|
||||
.byte %00000010 ; $08
|
||||
.byte %00000011 ; $09
|
||||
.byte %00010010 ; $0A
|
||||
.byte %00010011 ; $0B
|
||||
.byte %00001010 ; $0C
|
||||
.byte %00001011 ; $0D
|
||||
.byte %00011010 ; $0E
|
||||
.byte %00011011 ; $0F
|
||||
.byte %00000100 ; $10
|
||||
.byte %00000101 ; $11
|
||||
.byte %00010100 ; $12
|
||||
.byte %00010101 ; $13
|
||||
.byte %00001100 ; $14
|
||||
.byte %00001101 ; $15
|
||||
.byte %00011100 ; $16
|
||||
.byte %00011101 ; $17
|
||||
.byte %00000110 ; $18
|
||||
.byte %00000111 ; $19
|
||||
.byte %00010110 ; $1A
|
||||
.byte %00010111 ; $1B
|
||||
.byte %00001110 ; $1C
|
||||
.byte %00001111 ; $1D
|
||||
.byte %00011110 ; $1E
|
||||
.byte %00011111 ; $1F
|
||||
|
||||
.code
|
||||
|
||||
@ -100,21 +132,23 @@ COUNT: lda #JOY_COUNT
|
||||
;
|
||||
|
||||
READ: tax ; Clear high byte
|
||||
lda #$FD
|
||||
ldy #$FE
|
||||
lda #$FD ; For ENTER and '6'
|
||||
ldy #$FE ; For '8', '5', '2', '4'
|
||||
sei
|
||||
sta VIC_KBD_128
|
||||
lda CIA1_PRB
|
||||
and #%00110000
|
||||
eor #%00110000
|
||||
lsr
|
||||
lsr
|
||||
lsr ; Map ENTER ...
|
||||
lsr ; ... onto '5'
|
||||
sty VIC_KBD_128
|
||||
eor CIA1_PRB
|
||||
iny
|
||||
sty VIC_KBD_128 ; Reset to $FF
|
||||
cli
|
||||
and #%11111110
|
||||
eor #%11111110
|
||||
and #%00111110
|
||||
eor #%00111110
|
||||
lsr
|
||||
tay
|
||||
lda masktable,y ; Convert LDRBU to BRLDU
|
||||
rts
|
||||
|
||||
|
@ -29,17 +29,6 @@
|
||||
|
||||
.addr $0000
|
||||
|
||||
; Button state masks (8 values)
|
||||
|
||||
.byte $01 ; JOY_UP
|
||||
.byte $02 ; JOY_DOWN
|
||||
.byte $04 ; JOY_LEFT
|
||||
.byte $08 ; JOY_RIGHT
|
||||
.byte $10 ; JOY_FIRE
|
||||
.byte $00 ; JOY_FIRE2 unavailable
|
||||
.byte $00 ; Future expansion
|
||||
.byte $00 ; Future expansion
|
||||
|
||||
; Jump table.
|
||||
|
||||
.addr INSTALL
|
||||
@ -133,8 +122,8 @@ joy3:
|
||||
sta CIA2_PRB ; (output one at PB7)
|
||||
|
||||
lda CIA2_PRB ; cia 2 port B read/write
|
||||
and #$1f ; get bit 4-0 (PB4-PB0)
|
||||
eor #$1f
|
||||
and #$1F ; get bit 4-0 (PB4-PB0)
|
||||
eor #$1F
|
||||
rts
|
||||
|
||||
; Read joystick 4
|
||||
@ -143,14 +132,14 @@ joy4: lda #$00 ; cia 2 port B read/write
|
||||
sta CIA2_PRB ; (output zero at PB7)
|
||||
|
||||
lda CIA2_PRB ; cia 2 port B read/write
|
||||
and #$0f ; get bit 3-0 (PB3-PB0)
|
||||
and #$0F ; get bit 3-0 (PB3-PB0)
|
||||
sta tmp1 ; joy 4 directions
|
||||
|
||||
lda CIA2_PRB ; cia 2 port B read/write
|
||||
and #%00100000 ; get bit 5 (PB5)
|
||||
lsr
|
||||
ora tmp1
|
||||
eor #$1f
|
||||
eor #$1F
|
||||
|
||||
ldx #0
|
||||
rts
|
||||
|
@ -29,17 +29,6 @@
|
||||
|
||||
.addr $0000
|
||||
|
||||
; Button state masks (8 values)
|
||||
|
||||
.byte $01 ; JOY_UP
|
||||
.byte $02 ; JOY_DOWN
|
||||
.byte $04 ; JOY_LEFT
|
||||
.byte $08 ; JOY_RIGHT
|
||||
.byte $10 ; JOY_FIRE
|
||||
.byte $00 ; JOY_FIRE2 unavailable
|
||||
.byte $00 ; Future expansion
|
||||
.byte $00 ; Future expansion
|
||||
|
||||
; Jump table.
|
||||
|
||||
.addr INSTALL
|
||||
|
14
libsrc/c64/kbrepeat.s
Normal file
14
libsrc/c64/kbrepeat.s
Normal file
@ -0,0 +1,14 @@
|
||||
;
|
||||
; unsigned char __fastcall__ kbrepeat (unsigned char mode);
|
||||
;
|
||||
|
||||
.export _kbrepeat
|
||||
|
||||
.include "c64.inc"
|
||||
|
||||
_kbrepeat:
|
||||
ldx KBDREPEAT ; get old value
|
||||
sta KBDREPEAT ; store new value
|
||||
txa ; return old value
|
||||
ldx #0
|
||||
rts
|
18
libsrc/c64/waitvsync.s
Normal file
18
libsrc/c64/waitvsync.s
Normal file
@ -0,0 +1,18 @@
|
||||
;
|
||||
; Written by Groepaz <groepaz@gmx.net>
|
||||
;
|
||||
; void waitvsync (void);
|
||||
;
|
||||
|
||||
.export _waitvsync
|
||||
|
||||
.include "c64.inc"
|
||||
|
||||
_waitvsync:
|
||||
@l1:
|
||||
bit VIC_CTRL1
|
||||
bpl @l1
|
||||
@l2:
|
||||
bit VIC_CTRL1
|
||||
bmi @l2
|
||||
rts
|
@ -30,17 +30,6 @@
|
||||
|
||||
.addr $0000
|
||||
|
||||
; Button state masks (8 values)
|
||||
|
||||
.byte $01 ; JOY_UP
|
||||
.byte $02 ; JOY_DOWN
|
||||
.byte $04 ; JOY_LEFT
|
||||
.byte $08 ; JOY_RIGHT
|
||||
.byte $10 ; JOY_FIRE
|
||||
.byte $00 ; JOY_FIRE2 unavailable
|
||||
.byte $00 ; Future expansion
|
||||
.byte $00 ; Future expansion
|
||||
|
||||
; Jump table.
|
||||
|
||||
.addr INSTALL
|
||||
@ -105,7 +94,7 @@ READ: ldx #$0F ; Switch to the system bank
|
||||
lda (cia2),y ; Read joystick inputs
|
||||
sta tmp1
|
||||
|
||||
; Get the fire bits
|
||||
; Get the push button bits
|
||||
|
||||
ldy #CIA::PRA
|
||||
lda (cia2),y
|
||||
@ -115,12 +104,12 @@ READ: ldx #$0F ; Switch to the system bank
|
||||
cpx #$00 ; Joystick 0?
|
||||
bne @L1 ; Jump if no
|
||||
|
||||
; Joystick 1, fire is in bit 6, direction in bit 0-3
|
||||
; Joystick 1, push button is in bit 6, direction in bit 0-3
|
||||
|
||||
asl a
|
||||
jmp @L2
|
||||
|
||||
; Joystick 2, fire is in bit 7, direction in bit 5-7
|
||||
; Joystick 2, push button is in bit 7, direction in bit 5-7
|
||||
|
||||
@L1: ldx #$00 ; High byte of return value
|
||||
lsr tmp1
|
||||
@ -128,9 +117,9 @@ READ: ldx #$0F ; Switch to the system bank
|
||||
lsr tmp1
|
||||
lsr tmp1
|
||||
|
||||
; Mask the relavant bits, get the fire bit
|
||||
; Mask the relavant bits, get the push button bit
|
||||
|
||||
@L2: asl a ; Fire bit into carry
|
||||
@L2: asl a ; push button bit into carry
|
||||
lda tmp1
|
||||
and #$0F
|
||||
bcc @L3
|
||||
|
28
libsrc/cbm510/waitvsync.s
Normal file
28
libsrc/cbm510/waitvsync.s
Normal file
@ -0,0 +1,28 @@
|
||||
;
|
||||
; Written by Groepaz <groepaz@gmx.net>
|
||||
;
|
||||
; void waitvsync (void);
|
||||
;
|
||||
|
||||
.export _waitvsync
|
||||
.import PALFLAG
|
||||
.import sys_bank, restore_bank
|
||||
|
||||
.importzp vic
|
||||
|
||||
.include "cbm510.inc"
|
||||
|
||||
_waitvsync:
|
||||
jsr sys_bank ; Switch to the system bank
|
||||
sei
|
||||
|
||||
ldy #VIC_CTRL1
|
||||
@l1:
|
||||
lda (vic),y
|
||||
bpl @l1
|
||||
@l2:
|
||||
lda (vic),y
|
||||
bmi @l2
|
||||
|
||||
cli
|
||||
jmp restore_bank
|
286
libsrc/common/lz4.s
Normal file
286
libsrc/common/lz4.s
Normal file
@ -0,0 +1,286 @@
|
||||
;
|
||||
; Lauri Kasanen, 6 Jun 2017
|
||||
; (C) Mega Cat Studios
|
||||
; An optimized LZ4 decompressor
|
||||
;
|
||||
; Almost 7 times faster, uses no RAM (vs 14 bytes BSS), and takes 1/4 the space
|
||||
; vs the official C source.
|
||||
;
|
||||
|
||||
.importzp sp, sreg, regsave, regbank
|
||||
.importzp tmp1, tmp2, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4
|
||||
.macpack longbranch
|
||||
.import memcpy_upwards,pushax,popax
|
||||
.export _decompress_lz4
|
||||
|
||||
out = regsave
|
||||
written = regsave + 2
|
||||
tmp = tmp1
|
||||
token = tmp2
|
||||
offset = ptr3
|
||||
in = sreg
|
||||
outlen = ptr4
|
||||
|
||||
; ---------------------------------------------------------------
|
||||
; void decompress_lz4 (const u8 *in, u8 * const out, const u16 outlen)
|
||||
; ---------------------------------------------------------------
|
||||
|
||||
.segment "CODE"
|
||||
|
||||
.proc _decompress_lz4: near
|
||||
|
||||
sta outlen
|
||||
stx outlen+1
|
||||
|
||||
jsr popax
|
||||
sta out
|
||||
stx out+1
|
||||
|
||||
jsr popax
|
||||
sta in
|
||||
stx in+1
|
||||
|
||||
;
|
||||
; written = 0;
|
||||
;
|
||||
lda #$00
|
||||
sta written
|
||||
;
|
||||
; while (written < outlen) {
|
||||
;
|
||||
jmp L0046
|
||||
;
|
||||
; token = *in++;
|
||||
;
|
||||
L0004: ldy #$00
|
||||
lda (in),y
|
||||
sta token
|
||||
|
||||
inc in
|
||||
bne L000A
|
||||
inc in+1
|
||||
L000A:
|
||||
;
|
||||
; offset = token >> 4;
|
||||
;
|
||||
ldx #$00
|
||||
lsr a
|
||||
lsr a
|
||||
lsr a
|
||||
lsr a
|
||||
sta offset
|
||||
stx offset+1
|
||||
;
|
||||
; token &= 0xf;
|
||||
; token += 4; // Minmatch
|
||||
;
|
||||
lda token
|
||||
and #$0F
|
||||
clc
|
||||
adc #$04
|
||||
sta token
|
||||
;
|
||||
; if (offset == 15) {
|
||||
;
|
||||
lda offset
|
||||
cmp #$0F
|
||||
L0013: bne L001A
|
||||
;
|
||||
; tmp = *in++;
|
||||
;
|
||||
ldy #$00
|
||||
lda (in),y
|
||||
sta tmp
|
||||
|
||||
inc in
|
||||
bne L0017
|
||||
inc in+1
|
||||
L0017:
|
||||
;
|
||||
; offset += tmp;
|
||||
;
|
||||
clc
|
||||
adc offset
|
||||
sta offset
|
||||
lda #$00
|
||||
adc offset+1
|
||||
sta offset+1
|
||||
;
|
||||
; if (tmp == 255)
|
||||
;
|
||||
lda tmp
|
||||
cmp #$FF
|
||||
;
|
||||
; goto moreliterals;
|
||||
;
|
||||
jmp L0013
|
||||
;
|
||||
; if (offset) {
|
||||
;
|
||||
L001A: lda offset
|
||||
ora offset+1
|
||||
beq L001C
|
||||
;
|
||||
; memcpy(&out[written], in, offset);
|
||||
;
|
||||
lda out
|
||||
clc
|
||||
adc written
|
||||
sta ptr2
|
||||
lda out+1
|
||||
adc written+1
|
||||
tax
|
||||
lda ptr2
|
||||
stx ptr2+1
|
||||
jsr pushax
|
||||
lda in
|
||||
ldx in+1
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
; ldy #$00 - not needed as pushax zeroes Y
|
||||
jsr memcpy_upwards
|
||||
;
|
||||
; written += offset;
|
||||
;
|
||||
lda offset
|
||||
clc
|
||||
adc written
|
||||
sta written
|
||||
lda offset+1
|
||||
adc written+1
|
||||
sta written+1
|
||||
;
|
||||
; in += offset;
|
||||
;
|
||||
lda offset
|
||||
clc
|
||||
adc in
|
||||
sta in
|
||||
lda offset+1
|
||||
adc in+1
|
||||
sta in+1
|
||||
;
|
||||
; if (written >= outlen)
|
||||
;
|
||||
L001C: lda written
|
||||
cmp outlen
|
||||
lda written+1
|
||||
sbc outlen+1
|
||||
;
|
||||
; return;
|
||||
;
|
||||
bcc L0047
|
||||
rts
|
||||
;
|
||||
; memcpy(&offset, in, 2);
|
||||
;
|
||||
L0047: ldy #$00
|
||||
lda (in),y
|
||||
sta offset
|
||||
iny
|
||||
lda (in),y
|
||||
sta offset+1
|
||||
;
|
||||
; in += 2;
|
||||
;
|
||||
lda #$02
|
||||
clc
|
||||
adc in
|
||||
sta in
|
||||
bcc L002F
|
||||
inc in+1
|
||||
;
|
||||
; copysrc = out + written - offset;
|
||||
;
|
||||
L002F: lda out
|
||||
clc
|
||||
adc written
|
||||
tay
|
||||
lda out+1
|
||||
adc written+1
|
||||
tax
|
||||
tya
|
||||
sec
|
||||
sbc offset
|
||||
sta ptr1
|
||||
txa
|
||||
sbc offset+1
|
||||
sta ptr1+1
|
||||
;
|
||||
; offset = token;
|
||||
;
|
||||
lda #$00
|
||||
sta offset+1
|
||||
lda token
|
||||
sta offset
|
||||
;
|
||||
; if (token == 19) {
|
||||
;
|
||||
cmp #$13
|
||||
L0045: bne L003C
|
||||
;
|
||||
; tmp = *in++;
|
||||
;
|
||||
ldy #$00
|
||||
lda (in),y
|
||||
sta tmp
|
||||
|
||||
inc in
|
||||
bne L0039
|
||||
inc in+1
|
||||
L0039:
|
||||
;
|
||||
; offset += tmp;
|
||||
;
|
||||
clc
|
||||
adc offset
|
||||
sta offset
|
||||
tya
|
||||
adc offset+1
|
||||
sta offset+1
|
||||
;
|
||||
; if (tmp == 255)
|
||||
;
|
||||
lda tmp
|
||||
cmp #$FF
|
||||
;
|
||||
; goto morematches;
|
||||
;
|
||||
jmp L0045
|
||||
;
|
||||
; memcpy(&out[written], copysrc, offset);
|
||||
;
|
||||
L003C: lda out
|
||||
clc
|
||||
adc written
|
||||
sta ptr2
|
||||
lda out+1
|
||||
adc written+1
|
||||
tax
|
||||
lda ptr2
|
||||
stx ptr2+1
|
||||
jsr pushax
|
||||
jsr memcpy_upwards
|
||||
;
|
||||
; written += offset;
|
||||
;
|
||||
lda offset
|
||||
clc
|
||||
adc written
|
||||
sta written
|
||||
lda offset+1
|
||||
adc written+1
|
||||
L0046: sta written+1
|
||||
;
|
||||
; while (written < outlen) {
|
||||
;
|
||||
lda written
|
||||
cmp outlen
|
||||
lda written+1
|
||||
sbc outlen+1
|
||||
jcc L0004
|
||||
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
@ -1,6 +1,6 @@
|
||||
;
|
||||
; 2003-08-20, Ullrich von Bassewitz
|
||||
; 2009-09-13, Christian Krueger -- performance increase (about 20%)
|
||||
; 2009-09-13, Christian Krueger -- performance increase (about 20%), 2013-07-25 improved unrolling
|
||||
; 2015-10-23, Greg King
|
||||
;
|
||||
; void* __fastcall__ memmove (void* dest, const void* src, size_t size);
|
||||
@ -61,13 +61,10 @@ PageSizeCopy: ; assert Y = 0
|
||||
dec ptr1+1 ; adjust base...
|
||||
dec ptr2+1
|
||||
dey ; in entry case: 0 -> FF
|
||||
lda (ptr1),y ; need to copy this 'intro byte'
|
||||
sta (ptr2),y ; to 'land' later on Y=0! (as a result of the '.repeat'-block!)
|
||||
dey ; FF ->FE
|
||||
@copyBytes:
|
||||
.repeat 2 ; Unroll this a bit to make it faster...
|
||||
lda (ptr1),y
|
||||
sta (ptr2),y
|
||||
.repeat 3 ; unroll this a bit to make it faster...
|
||||
lda (ptr1),y ; important: unrolling three times gives a nice
|
||||
sta (ptr2),y ; 255/3 = 85 loop which ends at 0
|
||||
dey
|
||||
.endrepeat
|
||||
@copyEntry: ; in entry case: 0 -> FF
|
||||
|
@ -2,6 +2,7 @@
|
||||
; Randum number generator
|
||||
;
|
||||
; Written and donated by Sidney Cadot - sidney@ch.twi.tudelft.nl
|
||||
; 2016-11-07, modified by Brad Smith
|
||||
;
|
||||
; May be distributed with the cc65 runtime using the same license.
|
||||
;
|
||||
@ -13,10 +14,14 @@
|
||||
; Multiplier must be 1 (mod 4)
|
||||
; Added value must be 1 (mod 2)
|
||||
; This guarantees max. period (2**32)
|
||||
; Bits 8-22 are returned (positive 2-byte int)
|
||||
; where 0 is LSB, 31 is MSB.
|
||||
; This is better as lower bits exhibit easily
|
||||
; detectable patterns.
|
||||
; The lowest bits have poor entropy and
|
||||
; exhibit easily detectable patterns, so
|
||||
; only the upper bits 16-22 and 24-31 of the
|
||||
; 4-byte state are returned.
|
||||
;
|
||||
; The best 8 bits, 24-31 are returned in the
|
||||
; low byte A to provide the best entropy in the
|
||||
; most commonly used part of the return value.
|
||||
;
|
||||
|
||||
.export _rand, _srand
|
||||
|
@ -1,5 +1,6 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 31.05.1998
|
||||
; Christian Krueger: 2013-Jul-24, minor optimizations
|
||||
;
|
||||
; char* strcat (char* dest, const char* src);
|
||||
;
|
||||
@ -7,49 +8,44 @@
|
||||
.export _strcat
|
||||
.import popax
|
||||
.importzp ptr1, ptr2, tmp3
|
||||
.macpack cpu
|
||||
|
||||
_strcat:
|
||||
sta ptr1 ; Save src
|
||||
stx ptr1+1
|
||||
jsr popax ; Get dest
|
||||
sta ptr2
|
||||
stx ptr2+1
|
||||
sta tmp3 ; Remember for function return
|
||||
ldy #0
|
||||
sta ptr1 ; Save src
|
||||
stx ptr1+1
|
||||
jsr popax ; Get dest
|
||||
sta tmp3 ; Remember for function return
|
||||
tay
|
||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
||||
stz ptr2
|
||||
.else
|
||||
lda #0
|
||||
sta ptr2 ; access from page start, y contains low byte
|
||||
.endif
|
||||
stx ptr2+1
|
||||
|
||||
; find end of dest
|
||||
|
||||
sc1: lda (ptr2),y
|
||||
beq sc2
|
||||
findEndOfDest:
|
||||
lda (ptr2),y
|
||||
beq endOfDestFound
|
||||
iny
|
||||
bne sc1
|
||||
inc ptr2+1
|
||||
bne sc1
|
||||
bne findEndOfDest
|
||||
inc ptr2+1
|
||||
bne findEndOfDest
|
||||
|
||||
; end found, get offset in y into pointer
|
||||
endOfDestFound:
|
||||
sty ptr2 ; advance pointer to last y position
|
||||
ldy #0 ; reset new y-offset
|
||||
|
||||
sc2: tya
|
||||
clc
|
||||
adc ptr2
|
||||
sta ptr2
|
||||
bcc sc3
|
||||
inc ptr2+1
|
||||
|
||||
; copy src
|
||||
|
||||
sc3: ldy #0
|
||||
sc4: lda (ptr1),y
|
||||
sta (ptr2),y
|
||||
beq sc5
|
||||
copyByte:
|
||||
lda (ptr1),y
|
||||
sta (ptr2),y
|
||||
beq done
|
||||
iny
|
||||
bne sc4
|
||||
inc ptr1+1
|
||||
inc ptr2+1
|
||||
bne sc4
|
||||
bne copyByte
|
||||
inc ptr1+1
|
||||
inc ptr2+1
|
||||
bne copyByte ; like bra here
|
||||
|
||||
; done, return pointer to dest
|
||||
|
||||
sc5: lda tmp3 ; X does still contain high byte
|
||||
; return pointer to dest
|
||||
done: lda tmp3 ; X does still contain high byte
|
||||
rts
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 31.05.1998
|
||||
; Christian Krueger, 2013-Aug-04, minor optimization
|
||||
;
|
||||
; const char* strchr (const char* s, int c);
|
||||
;
|
||||
@ -7,42 +8,45 @@
|
||||
.export _strchr
|
||||
.import popax
|
||||
.importzp ptr1, tmp1
|
||||
.macpack cpu
|
||||
|
||||
_strchr:
|
||||
sta tmp1 ; Save c
|
||||
jsr popax ; get s
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
ldy #0
|
||||
sta tmp1 ; Save c
|
||||
jsr popax ; get s
|
||||
tay ; low byte of pointer to y
|
||||
stx ptr1+1
|
||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
||||
stz ptr1
|
||||
.else
|
||||
lda #0
|
||||
sta ptr1 ; access from page start, y contains low byte
|
||||
.endif
|
||||
|
||||
Loop: lda (ptr1),y ; Get next char
|
||||
beq EOS ; Jump on end of string
|
||||
cmp tmp1 ; Found?
|
||||
beq Found ; Jump if yes
|
||||
Loop: lda (ptr1),y ; Get next char
|
||||
beq EOS ; Jump on end of string
|
||||
cmp tmp1 ; Found?
|
||||
beq Found ; Jump if yes
|
||||
iny
|
||||
bne Loop
|
||||
inc ptr1+1
|
||||
bne Loop ; Branch always
|
||||
bne Loop
|
||||
inc ptr1+1
|
||||
bne Loop ; Branch always
|
||||
|
||||
; End of string. Check if we're searching for the terminating zero
|
||||
|
||||
EOS: lda tmp1 ; Get the char we're searching for
|
||||
bne NotFound ; Jump if not searching for terminator
|
||||
EOS:
|
||||
lda tmp1 ; Get the char we're searching for
|
||||
bne NotFound ; Jump if not searching for terminator
|
||||
|
||||
; Found. Calculate pointer to c.
|
||||
; Found. Set pointer to c.
|
||||
|
||||
Found: ldx ptr1+1 ; Load high byte of pointer
|
||||
tya ; Low byte offset
|
||||
clc
|
||||
adc ptr1
|
||||
bcc Found1
|
||||
inx
|
||||
Found1: rts
|
||||
Found:
|
||||
ldx ptr1+1 ; Load high byte of pointer
|
||||
tya ; low byte is in y
|
||||
rts
|
||||
|
||||
; Not found, return NULL
|
||||
|
||||
NotFound:
|
||||
lda #0
|
||||
lda #0
|
||||
tax
|
||||
rts
|
||||
|
||||
|
@ -1,54 +1,53 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 11.06.1998
|
||||
; Christian Krueger: 05-Aug-2013, optimization
|
||||
;
|
||||
; size_t strcspn (const char* s1, const char* s2);
|
||||
;
|
||||
|
||||
.export _strcspn
|
||||
.import popax
|
||||
.importzp ptr1, ptr2, tmp1, tmp2, tmp3
|
||||
.import popax, _strlen
|
||||
.importzp ptr1, ptr2, tmp1, tmp2
|
||||
|
||||
_strcspn:
|
||||
sta ptr2 ; Save s2
|
||||
stx ptr2+1
|
||||
jsr popax ; Get s1
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
ldx #0 ; low counter byte
|
||||
stx tmp1 ; high counter byte
|
||||
ldy #$00
|
||||
jsr _strlen ; get length in a/x and transfer s2 to ptr1
|
||||
; Note: It does not make sense to
|
||||
; have more than 255 test chars, so
|
||||
; we don't support a high byte here! (ptr1+1 is
|
||||
; also unchanged in strlen then (important!))
|
||||
; -> the original implementation also
|
||||
; ignored this case
|
||||
|
||||
L1: lda (ptr1),y ; get next char from s1
|
||||
beq L6 ; jump if done
|
||||
sta tmp2 ; save char
|
||||
sta tmp1 ; tmp1 = strlen of test chars
|
||||
jsr popax ; get and save s1
|
||||
sta ptr2 ; to ptr2
|
||||
stx ptr2+1
|
||||
ldx #0 ; low counter byte
|
||||
stx tmp2 ; high counter byte
|
||||
|
||||
loadChar:
|
||||
ldy #0
|
||||
lda (ptr2),y ; get next char from s1
|
||||
beq leave ; handly byte of s1
|
||||
advance:
|
||||
inc ptr2 ; advance string position to test
|
||||
bne check
|
||||
inc ptr2+1
|
||||
dey ; correct next iny (faster/shorter than bne...)
|
||||
|
||||
checkNext:
|
||||
iny
|
||||
bne L2
|
||||
inc ptr1+1
|
||||
L2: sty tmp3 ; save index into s1
|
||||
check: cpy tmp1 ; compare with length of test character string
|
||||
beq endOfTestChars
|
||||
cmp (ptr1),y ; found matching char?
|
||||
bne checkNext
|
||||
|
||||
ldy #0 ; get index into s2
|
||||
L3: lda (ptr2),y ;
|
||||
beq L4 ; jump if done
|
||||
cmp tmp2
|
||||
beq L6
|
||||
iny
|
||||
bne L3
|
||||
|
||||
; The character was not found in s2. Increment the counter and start over
|
||||
|
||||
L4: ldy tmp3 ; reload index
|
||||
inx
|
||||
bne L1
|
||||
inc tmp1
|
||||
bne L1
|
||||
|
||||
; The character was found, or we reached the end of s1. Return count of
|
||||
; characters
|
||||
|
||||
L6: txa ; get low counter byte
|
||||
ldx tmp1 ; get high counter byte
|
||||
leave: txa ; restore position of finding
|
||||
ldx tmp2 ; and return
|
||||
rts
|
||||
|
||||
|
||||
|
||||
|
||||
endOfTestChars:
|
||||
inx
|
||||
bne loadChar
|
||||
inc tmp2
|
||||
bne loadChar ; like bra...
|
||||
|
@ -53,11 +53,11 @@
|
||||
size_t __fastcall__ strftime (char* buf, size_t bufsize, const char* format,
|
||||
const struct tm* tm)
|
||||
{
|
||||
static const char* days[7] = {
|
||||
static const char* const days[7] = {
|
||||
"Sunday", "Monday", "Tuesday", "Wednesday",
|
||||
"Thursday", "Friday", "Saturday"
|
||||
};
|
||||
static const char* months[12] = {
|
||||
static const char* const months[12] = {
|
||||
"January", "February", "March", "April", "May", "June",
|
||||
"July", "August", "September", "October", "November", "December"
|
||||
};
|
||||
|
@ -1,6 +1,10 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 31.05.1998
|
||||
;
|
||||
; Note: strspn & strcspn call internally this function and rely on
|
||||
; the usage of only ptr1 here! Keep in mind when appling changes
|
||||
; and check the other implementations too!
|
||||
;
|
||||
; int strlen (const char* s);
|
||||
;
|
||||
|
||||
@ -23,4 +27,3 @@ L1: lda (ptr1),y
|
||||
|
||||
L9: tya ; get low byte of counter, hi's all set
|
||||
rts
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 31.05.1998
|
||||
; Christian Krueger: 12-Aug-2013, minor optimizations
|
||||
;
|
||||
; char* strncat (char* dest, const char* src, size_t n);
|
||||
;
|
||||
@ -7,66 +8,66 @@
|
||||
.export _strncat
|
||||
.import popax
|
||||
.importzp ptr1, ptr2, ptr3, tmp1, tmp2
|
||||
|
||||
.macpack cpu
|
||||
|
||||
_strncat:
|
||||
eor #$FF ; one's complement to count upwards
|
||||
sta tmp1
|
||||
txa
|
||||
eor #$FF
|
||||
sta tmp2
|
||||
jsr popax ; get src
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
jsr popax ; get dest
|
||||
sta ptr2
|
||||
stx ptr2+1
|
||||
sta ptr3 ; remember for function return
|
||||
stx ptr3+1
|
||||
ldy #0
|
||||
eor #$FF ; one's complement to count upwards
|
||||
sta tmp1
|
||||
txa
|
||||
eor #$FF
|
||||
sta tmp2
|
||||
|
||||
jsr popax ; get src
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
|
||||
jsr popax ; get dest
|
||||
sta ptr3 ; remember for function return
|
||||
stx ptr3+1
|
||||
stx ptr2+1
|
||||
tay ; low byte as offset in Y
|
||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
||||
stz ptr2
|
||||
.else
|
||||
ldx #0
|
||||
stx ptr2 ; destination on page boundary
|
||||
.endif
|
||||
|
||||
; find end of dest
|
||||
|
||||
L1: lda (ptr2),y
|
||||
beq L2
|
||||
iny
|
||||
bne L1
|
||||
inc ptr2+1
|
||||
bne L1
|
||||
L1: lda (ptr2),y
|
||||
beq L2
|
||||
iny
|
||||
bne L1
|
||||
inc ptr2+1
|
||||
bne L1
|
||||
|
||||
; end found, get offset in y into pointer
|
||||
|
||||
L2: tya
|
||||
clc
|
||||
adc ptr2
|
||||
sta ptr2
|
||||
bcc L3
|
||||
inc ptr2+1
|
||||
; end found, apply offset to dest ptr and reset y
|
||||
L2: sty ptr2
|
||||
|
||||
; copy src. We've put the ones complement of the count into the counter, so
|
||||
; we'll increment the counter on top of the loop
|
||||
|
||||
L3: ldy #0
|
||||
ldx tmp1 ; low counter byte
|
||||
L3: ldy #0
|
||||
ldx tmp1 ; low counter byte
|
||||
|
||||
L4: inx
|
||||
bne L5
|
||||
inc tmp2
|
||||
beq L6 ; jump if done
|
||||
L5: lda (ptr1),y
|
||||
sta (ptr2),y
|
||||
beq L7
|
||||
iny
|
||||
bne L4
|
||||
inc ptr1+1
|
||||
inc ptr2+1
|
||||
bne L4
|
||||
L4: inx
|
||||
bne L5
|
||||
inc tmp2
|
||||
beq L6 ; jump if done
|
||||
L5: lda (ptr1),y
|
||||
sta (ptr2),y
|
||||
beq L7
|
||||
iny
|
||||
bne L4
|
||||
inc ptr1+1
|
||||
inc ptr2+1
|
||||
bne L4
|
||||
|
||||
; done, set the trailing zero and return pointer to dest
|
||||
|
||||
L6: lda #0
|
||||
sta (ptr2),y
|
||||
L7: lda ptr3
|
||||
ldx ptr3+1
|
||||
rts
|
||||
|
||||
|
||||
L6: lda #0
|
||||
sta (ptr2),y
|
||||
L7: lda ptr3
|
||||
ldx ptr3+1
|
||||
rts
|
||||
|
@ -1,47 +1,41 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 31.05.1998
|
||||
; Christian Krueger: 2013-Aug-01, optimization
|
||||
;
|
||||
; char* strrchr (const char* s, int c);
|
||||
;
|
||||
|
||||
.export _strrchr
|
||||
.import popax
|
||||
.importzp ptr1, ptr2, tmp1
|
||||
.importzp ptr1, tmp1, tmp2
|
||||
|
||||
_strrchr:
|
||||
sta tmp1 ; Save c
|
||||
jsr popax ; get s
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
lda #0 ; function result = NULL
|
||||
sta ptr2
|
||||
sta ptr2+1
|
||||
tay
|
||||
sta tmp1 ; Save c
|
||||
jsr popax ; get s
|
||||
tay ; low byte to y
|
||||
stx ptr1+1
|
||||
ldx #0 ; default function result is NULL, X is high byte...
|
||||
stx tmp2 ; tmp2 is low-byte
|
||||
stx ptr1 ; low-byte of source string is in Y, so clear real one...
|
||||
|
||||
testChar:
|
||||
lda (ptr1),y ; get char
|
||||
beq finished ; jump if end of string
|
||||
cmp tmp1 ; found?
|
||||
bne nextChar ; jump if no
|
||||
|
||||
L1: lda (ptr1),y ; get next char
|
||||
beq L3 ; jump if end of string
|
||||
cmp tmp1 ; found?
|
||||
bne L2 ; jump if no
|
||||
charFound:
|
||||
sty tmp2 ; y has low byte of location, save it
|
||||
ldx ptr1+1 ; x holds high-byte of result
|
||||
|
||||
; Remember a pointer to the character
|
||||
nextChar:
|
||||
iny
|
||||
bne testChar
|
||||
inc ptr1+1
|
||||
bne testChar ; here like bra...
|
||||
|
||||
tya
|
||||
clc
|
||||
adc ptr1
|
||||
sta ptr2
|
||||
lda ptr1+1
|
||||
adc #$00
|
||||
sta ptr2+1
|
||||
; return the pointer to the last occurrence
|
||||
|
||||
; Next char
|
||||
|
||||
L2: iny
|
||||
bne L1
|
||||
inc ptr1+1
|
||||
bne L1 ; jump always
|
||||
|
||||
; Return the pointer to the last occurrence
|
||||
|
||||
L3: lda ptr2
|
||||
ldx ptr2+1
|
||||
finished:
|
||||
lda tmp2 ; high byte in X is already correct...
|
||||
rts
|
||||
|
@ -1,56 +1,53 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 11.06.1998
|
||||
; Christian Krueger: 08-Aug-2013, optimization
|
||||
;
|
||||
; size_t strspn (const char* s1, const char* s2);
|
||||
;
|
||||
|
||||
.export _strspn
|
||||
.import popax
|
||||
.importzp ptr1, ptr2, tmp1, tmp2, tmp3
|
||||
.import popax, _strlen
|
||||
.importzp ptr1, ptr2, tmp1, tmp2
|
||||
|
||||
_strspn:
|
||||
sta ptr2 ; Save s2
|
||||
stx ptr2+1
|
||||
jsr popax ; get s1
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
ldx #0 ; low counter byte
|
||||
stx tmp1 ; high counter byte
|
||||
ldy #$00
|
||||
jsr _strlen ; get length in a/x and transfer s2 to ptr1
|
||||
; Note: It does not make sense to
|
||||
; have more than 255 test chars, so
|
||||
; we don't support a high byte here! (ptr1+1 is
|
||||
; also unchanged in strlen then (important!))
|
||||
; -> the original implementation also
|
||||
; ignored this case
|
||||
|
||||
L1: lda (ptr1),y ; get next char from s1
|
||||
beq L6 ; jump if done
|
||||
sta tmp2 ; save char
|
||||
sta tmp1 ; tmp1 = strlen of test chars
|
||||
jsr popax ; get and save s1
|
||||
sta ptr2 ; to ptr2
|
||||
stx ptr2+1
|
||||
ldx #0 ; low counter byte
|
||||
stx tmp2 ; high counter byte
|
||||
|
||||
loadChar:
|
||||
ldy #0
|
||||
lda (ptr2),y ; get next char from s1
|
||||
beq leave ; handly byte of s1
|
||||
advance:
|
||||
inc ptr2 ; advance string position to test
|
||||
bne check
|
||||
inc ptr2+1
|
||||
dey ; correct next iny (faster/shorter than bne...)
|
||||
|
||||
checkNext:
|
||||
iny
|
||||
bne L2
|
||||
inc ptr1+1
|
||||
L2: sty tmp3 ; save index into s1
|
||||
check: cpy tmp1 ; compare with length of test character string
|
||||
beq leave
|
||||
cmp (ptr1),y ; found matching char?
|
||||
bne checkNext
|
||||
|
||||
ldy #0 ; get index into s2
|
||||
L3: lda (ptr2),y ;
|
||||
beq L6 ; jump if done
|
||||
cmp tmp2
|
||||
beq L4
|
||||
iny
|
||||
bne L3
|
||||
|
||||
; The character was found in s2. Increment the counter and start over
|
||||
|
||||
L4: ldy tmp3 ; reload index
|
||||
foundTestChar:
|
||||
inx
|
||||
bne L1
|
||||
inc tmp1
|
||||
bne L1
|
||||
bne loadChar
|
||||
inc tmp2
|
||||
bne loadChar ; like bra...
|
||||
|
||||
; The character was not found, or we reached the end of s1. Return count of
|
||||
; characters
|
||||
|
||||
L6: txa ; get low counter byte
|
||||
ldx tmp1 ; get high counter byte
|
||||
leave: txa ; restore position of finding
|
||||
ldx tmp2 ; and return
|
||||
rts
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 06.08.1998
|
||||
;
|
||||
; void cputsxy (unsigned char x, unsigned char y, char* s);
|
||||
; void cputs (char* s);
|
||||
; void cputsxy (unsigned char x, unsigned char y, const char* s);
|
||||
; void cputs (const char* s);
|
||||
;
|
||||
|
||||
.export _cputsxy, _cputs
|
||||
|
@ -18,7 +18,7 @@ _clrscr:
|
||||
lda #$50 ; VRAM offset high ($10 OR $40)
|
||||
sta VDP_CONTROL_W
|
||||
|
||||
lda #$C0 ; Space from ROM setup
|
||||
lda #$40 ; Space char from ROM setup
|
||||
|
||||
ldx #0
|
||||
ldy #3
|
||||
@ -34,8 +34,8 @@ L1: sta VDP_DATA_W
|
||||
lda #0
|
||||
sta CURSOR_X
|
||||
sta CURSOR_Y
|
||||
sta <SCREEN_PTR
|
||||
sta SCREEN_PTR
|
||||
lda #$10
|
||||
sta >SCREEN_PTR
|
||||
sta SCREEN_PTR+1
|
||||
|
||||
rts
|
||||
|
@ -96,8 +96,8 @@ BAD_CHAR:
|
||||
jmp plot
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
; Initialize the conio subsystem. Code goes into the INIT segment, which may
|
||||
; be reused after startup.
|
||||
; Initialize the conio subsystem. "INIT" segment is nothing special on the
|
||||
; Creativision, it is part of the "ROM" memory.
|
||||
|
||||
.segment "INIT"
|
||||
|
||||
@ -122,4 +122,4 @@ LL: lda boxchars,x
|
||||
bne LL
|
||||
|
||||
cli
|
||||
jmp plot
|
||||
jmp plot
|
||||
|
@ -31,9 +31,6 @@ entry:
|
||||
ldx #<__RAM_START__ - 1
|
||||
txs
|
||||
|
||||
; Start interrupts
|
||||
cli
|
||||
|
||||
; Clear the BSS data
|
||||
jsr zerobss
|
||||
|
||||
@ -49,13 +46,21 @@ entry:
|
||||
; Call module constructors
|
||||
jsr initlib
|
||||
|
||||
; enable vertical blank interrupts in the display controller
|
||||
lda #$E0 ; 16K RAM, Active Display, Mode 1, VBI enabled
|
||||
ldx #$01 ; Register 1
|
||||
jsr BIOS_WRITE_VDP_REG
|
||||
|
||||
; Start interrupts
|
||||
cli
|
||||
|
||||
; Call main()
|
||||
jsr callmain
|
||||
|
||||
; Call module destructors. This is also the _exit entry.
|
||||
_exit: jsr donelib
|
||||
|
||||
; TODO: Replace with some sort of reset
|
||||
; A Creativision program isn't supposed to exit.
|
||||
loop: jmp loop
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@ -81,7 +86,7 @@ irq2: jmp BIOS_IRQ2_ADDR
|
||||
; VDP Setup
|
||||
; This sets to Graphics Mode 1
|
||||
.byte $00 ; Register 0
|
||||
.byte $C0 ; Register 1 16K RAM, Active Display, Mode 1
|
||||
.byte $C0 ; Register 1 16K RAM, Active Display, Mode 1, VBI disabled
|
||||
.byte $04 ; Register 2 Name Table at $1000 - $12FF
|
||||
.byte $60 ; Register 3 Colour Table at $1800 - $181F
|
||||
.byte $00 ; Register 4 Pattern Table at $0000 - $07FF
|
||||
|
@ -1,15 +1,19 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 06.08.1998
|
||||
; 1998-08-06, Ullrich von Bassewitz
|
||||
; 2017-06-15, Greg King
|
||||
;
|
||||
; void gotoxy (unsigned char x, unsigned char y);
|
||||
;
|
||||
|
||||
.export _gotoxy
|
||||
.export gotoxy, _gotoxy
|
||||
|
||||
.import setcursor
|
||||
.import popa
|
||||
|
||||
.include "creativision.inc"
|
||||
|
||||
gotoxy: jsr popa ; Get Y
|
||||
|
||||
.proc _gotoxy
|
||||
|
||||
sta CURSOR_Y ; Set Y
|
||||
|
@ -1,60 +1,56 @@
|
||||
;
|
||||
; Standard joystick driver for the Creativision.
|
||||
;
|
||||
; Christian Groessler, 2017-02-06
|
||||
; Christian Groessler, 2017-03-08
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "joy-kernel.inc"
|
||||
.include "joy-error.inc"
|
||||
.include "creativision.inc"
|
||||
.include "joy-kernel.inc"
|
||||
.include "joy-error.inc"
|
||||
.include "creativision.inc"
|
||||
|
||||
.macpack module
|
||||
.macpack module
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Header. Includes jump table
|
||||
|
||||
module_header _creativisionstd_joy
|
||||
module_header _creativisionstd_joy
|
||||
|
||||
; Driver signature
|
||||
|
||||
.byte $6A, $6F, $79 ; "joy"
|
||||
.byte JOY_API_VERSION ; Driver API version number
|
||||
.byte $6A, $6F, $79 ; "joy"
|
||||
.byte JOY_API_VERSION ; Driver API version number
|
||||
|
||||
; Library reference
|
||||
|
||||
.addr $0000
|
||||
|
||||
; Button state masks (8 values)
|
||||
|
||||
.byte $10 ; JOY_UP
|
||||
.byte $04 ; JOY_DOWN
|
||||
.byte $20 ; JOY_LEFT
|
||||
.byte $08 ; JOY_RIGHT
|
||||
.byte $01 ; JOY_FIRE (button #1)
|
||||
.byte $02 ; JOY_FIRE2 (button #2)
|
||||
.byte $00 ; Future expansion
|
||||
.byte $00 ; Future expansion
|
||||
.addr $0000
|
||||
|
||||
; Jump table.
|
||||
|
||||
.addr INSTALL
|
||||
.addr UNINSTALL
|
||||
.addr COUNT
|
||||
.addr READJOY
|
||||
.addr 0 ; IRQ entry not used
|
||||
.addr INSTALL
|
||||
.addr UNINSTALL
|
||||
.addr COUNT
|
||||
.addr READJOY
|
||||
.addr 0 ; IRQ entry not used
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Constants
|
||||
|
||||
JOY_COUNT = 2 ; Number of joysticks we support
|
||||
JOY_COUNT = 2 ; Number of joysticks we support
|
||||
|
||||
; Symbolic names for joystick masks (similar names like the defines in joystick.h, but not related to them)
|
||||
|
||||
JOY_UP = $10
|
||||
JOY_DOWN = $04
|
||||
JOY_LEFT = $20
|
||||
JOY_RIGHT = $08
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Code
|
||||
|
||||
.code
|
||||
.code
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; INSTALL routine. Is called after the driver is loaded into memory. If
|
||||
@ -63,131 +59,180 @@ JOY_COUNT = 2 ; Number of joysticks we support
|
||||
; Must return an JOY_ERR_xx code in a/x.
|
||||
;
|
||||
|
||||
INSTALL:
|
||||
lda #JOY_ERR_OK
|
||||
ldx #0
|
||||
; rts ; Fall through
|
||||
INSTALL: lda #JOY_ERR_OK
|
||||
ldx #0
|
||||
; rts ; Fall through
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; UNINSTALL routine. Is called before the driver is removed from memory.
|
||||
; Can do cleanup or whatever. Must not return anything.
|
||||
;
|
||||
|
||||
UNINSTALL:
|
||||
rts
|
||||
UNINSTALL: rts
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; COUNT: Return the total number of available joysticks in a/x.
|
||||
;
|
||||
|
||||
COUNT:
|
||||
lda #<JOY_COUNT
|
||||
ldx #>JOY_COUNT
|
||||
rts
|
||||
COUNT: lda #<JOY_COUNT
|
||||
ldx #>JOY_COUNT
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; READ: Read a particular joystick passed in A.
|
||||
;
|
||||
|
||||
READJOY:
|
||||
and #1 ; fix joystick number
|
||||
bne READJOY_1 ; read right joystick
|
||||
READJOY: and #1 ; fix joystick number
|
||||
bne READJOY_1 ; read right joystick
|
||||
|
||||
; Read left joystick
|
||||
|
||||
ldx ZP_JOY0_DIR
|
||||
lda ZP_JOY0_BUTTONS
|
||||
jmp convert ; convert joystick state to sane cc65 values
|
||||
ldx ZP_JOY0_DIR
|
||||
lda ZP_JOY0_BUTTONS
|
||||
jmp convert ; convert joystick state to cc65 values
|
||||
|
||||
; Read right joystick
|
||||
|
||||
READJOY_1:
|
||||
|
||||
ldx ZP_JOY1_DIR
|
||||
lda ZP_JOY1_BUTTONS
|
||||
lsr a
|
||||
lsr a
|
||||
;jmp convert ; convert joystick state to sane cc65 values
|
||||
; fall thru...
|
||||
READJOY_1: ldx ZP_JOY1_DIR
|
||||
lda ZP_JOY1_BUTTONS
|
||||
lsr a
|
||||
lsr a
|
||||
;jmp convert ; convert joystick state to cc65 values
|
||||
; fall thru...
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; convert: make runtime lib compatible values
|
||||
; A - buttons
|
||||
; X - direction
|
||||
; inputs:
|
||||
; A - buttons
|
||||
; X - direction
|
||||
;
|
||||
|
||||
convert:
|
||||
ldy #0
|
||||
sty retval ; initialize return value
|
||||
|
||||
; ------
|
||||
; buttons:
|
||||
; Port values are for the left hand joystick (right hand joystick
|
||||
; values were shifted to the right to be identical).
|
||||
; Why are there two bits indicating a pressed trigger?
|
||||
; According to the "Second book of programs for the Dick Smith Wizard"
|
||||
; (pg. 88ff), the left hand fire button gives the value of
|
||||
; %00010001 and the right hand button gives %00100010
|
||||
; Why two bits? Am I missing something? Can there be cases that just
|
||||
; one of those bits is set?
|
||||
; We just test if any of those two bits is not zero...
|
||||
; Port values are for the left hand joystick (right hand joystick
|
||||
; values were shifted to the right to be identical).
|
||||
; Why are there two bits indicating a pressed trigger?
|
||||
; According to the "Second book of programs for the Dick Smith Wizard"
|
||||
; (pg. 88ff), the left hand button gives the value of
|
||||
; %00010001 and the right hand button gives %00100010
|
||||
; Why two bits? Can there be cases that just one of those bits is set?
|
||||
; Until these questions have been answered, we only use the lower two
|
||||
; bits and ignore the upper ones...
|
||||
|
||||
tay
|
||||
and #%00010001
|
||||
beq cnv_1
|
||||
|
||||
inc retval ; left button pressed
|
||||
|
||||
cnv_1: tya
|
||||
and #%00100010
|
||||
beq cnv_2
|
||||
|
||||
lda #$02
|
||||
ora retval
|
||||
sta retval ; right button pressed
|
||||
and #%00000011 ; button status came in in A, strip high bits
|
||||
sta retval ; initialize 'retval' with button status
|
||||
|
||||
; ------
|
||||
; direction:
|
||||
cnv_2: txa
|
||||
; tested with https://sourceforge.net/projects/creativisionemulator
|
||||
; $49 - %01001001 - up
|
||||
; $41 - %01000001 - down
|
||||
; $4D - %01001101 - left
|
||||
; $45 - %01000101 - right
|
||||
;
|
||||
; are these correct? "Second book of programs for the Dick Smith Wizard" pg. 85 says something different
|
||||
; ignored for now...
|
||||
; $85 - %10000101 - up + right
|
||||
; $8D - %10001101 - down + left
|
||||
; $89 - %10001001 - up + left
|
||||
; $85 - %10000101 - down + right (emulator bug?)
|
||||
; CV has a 16-direction joystick
|
||||
;
|
||||
; port values: (compass points)
|
||||
; N - $49 - %01001001
|
||||
; NNE - $48 - %01001000
|
||||
; NE - $47 - %01000111
|
||||
; ENE - $46 - %01000110
|
||||
; E - $45 - %01000101
|
||||
; ESE - $44 - %01000100
|
||||
; SE - $43 - %01000011
|
||||
; SSE - $42 - %01000010
|
||||
; S - $41 - %01000001
|
||||
; SSW - $40 - %01000000
|
||||
; SW - $4F - %01001111
|
||||
; WSW - $4E - %01001110
|
||||
; W - $4D - %01001101
|
||||
; WNW - $4C - %01001100
|
||||
; NW - $4B - %01001011
|
||||
; NNW - $4A - %01001010
|
||||
; center - $00 - %00000000
|
||||
;
|
||||
; mapping to cc65 definitions (4-direction joystick with 8 possible directions thru combinations)
|
||||
; N, E, S, W -> JOY_UP, JOY_RIGHT, JOY_DOWN, JOY_LEFT
|
||||
; NE, SE, SW, NW -> (JOY_UP | JOY_RIGHT), (JOY_DOWN | JOY_RIGHT), (JOY_DOWN | JOY_LEFT), (JOY_UP | JOY_LEFT)
|
||||
; NNE, ENE, ESE, SSE, SSW, WSW, WNW, NNW:
|
||||
; toggle between straight and diagonal direction for every call, e.g.
|
||||
; NNE:
|
||||
; call to READJOY: return JOY_UP | JOY_RIGHT
|
||||
; call to READJOY: return JOY_UP
|
||||
; call to READJOY: return JOY_UP | JOY_RIGHT
|
||||
; call to READJOY: return JOY_UP
|
||||
; call to READJOY: return JOY_UP | JOY_RIGHT
|
||||
; etc...
|
||||
|
||||
bit testbit ; bit #0 set?
|
||||
beq done ; no, no direction
|
||||
txa ; move direction status into A
|
||||
beq done ; center position (no bits are set), nothing to do
|
||||
|
||||
and #%00001100 ; mask out other bits
|
||||
lsr a
|
||||
lsr a
|
||||
tax
|
||||
lda #%00000100 ; init bitmask
|
||||
loop: dex
|
||||
bmi done2
|
||||
asl a
|
||||
bne loop
|
||||
and #$0F ; get rid of the "$40" bit
|
||||
bit bit0 ; is it a "three letter" direction (NNE, ENE, etc.)?
|
||||
beq special ; yes (bit #0 is zero)
|
||||
|
||||
done2: ora retval
|
||||
rts
|
||||
lsr a ; create index into table
|
||||
tax
|
||||
lda dirtable,x
|
||||
done: ora retval ; include "button" bits
|
||||
ldx #0
|
||||
rts
|
||||
|
||||
done: lda retval
|
||||
rts
|
||||
; NNE, ENE, ESE, SSE, SSW, WSW, WNW, NNW
|
||||
|
||||
special: lsr a
|
||||
tax
|
||||
|
||||
lda toggler ; toggle the toggler
|
||||
eor #$01
|
||||
sta toggler
|
||||
bne spec_1 ; toggler is 1, use spectable_1 entry
|
||||
|
||||
lda spectable_0,x ; toggler is 0, use spectable_0 entry
|
||||
bne done ; jump always
|
||||
|
||||
spec_1: lda spectable_1,x
|
||||
bne done ; jump always
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
;
|
||||
.data
|
||||
testbit:.byte $01
|
||||
.rodata
|
||||
|
||||
; a mapping table of "port values" to "cc65 values"
|
||||
; port value had been shifted one bit to the right (range 0..7)
|
||||
dirtable: .byte JOY_DOWN ; S
|
||||
.byte JOY_DOWN | JOY_RIGHT ; SE
|
||||
.byte JOY_RIGHT ; E
|
||||
.byte JOY_UP | JOY_RIGHT ; NE
|
||||
.byte JOY_UP ; N
|
||||
.byte JOY_UP | JOY_LEFT ; NW
|
||||
.byte JOY_LEFT ; W
|
||||
.byte JOY_DOWN | JOY_LEFT ; SW
|
||||
|
||||
; two "special" mapping tables for three-letter directions (NNE, etc.)
|
||||
spectable_0: .byte JOY_DOWN ; SSW
|
||||
.byte JOY_DOWN ; SSE
|
||||
.byte JOY_RIGHT ; ESE
|
||||
.byte JOY_RIGHT ; ENE
|
||||
.byte JOY_RIGHT ; NNE
|
||||
.byte JOY_UP ; NNW
|
||||
.byte JOY_LEFT ; WNW
|
||||
.byte JOY_LEFT ; WSW
|
||||
|
||||
spectable_1: .byte JOY_DOWN | JOY_LEFT ; SSW
|
||||
.byte JOY_DOWN | JOY_RIGHT ; SSE
|
||||
.byte JOY_DOWN | JOY_RIGHT ; ESE
|
||||
.byte JOY_UP | JOY_RIGHT ; ENE
|
||||
.byte JOY_UP | JOY_RIGHT ; NNE
|
||||
.byte JOY_UP | JOY_LEFT ; NNW
|
||||
.byte JOY_UP | JOY_LEFT ; WNW
|
||||
.byte JOY_DOWN | JOY_LEFT ; WSW
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
;
|
||||
.bss
|
||||
retval: .res 0
|
||||
bit0: .byte $01
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
;
|
||||
.bss
|
||||
toggler: .res 1
|
||||
retval: .res 1
|
||||
|
||||
.end
|
||||
|
@ -1,22 +0,0 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 2003-03-07
|
||||
;
|
||||
; Setup arguments for main
|
||||
;
|
||||
|
||||
|
||||
.constructor initmainargs, 24
|
||||
.import __argc, __argv
|
||||
|
||||
|
||||
;---------------------------------------------------------------------------
|
||||
; Get possible command-line arguments. Goes into the special INIT segment,
|
||||
; which may be reused after the startup code is run
|
||||
|
||||
.segment "INIT"
|
||||
|
||||
.proc initmainargs
|
||||
|
||||
rts
|
||||
|
||||
.endproc
|
@ -32,7 +32,7 @@ static char DumpHandler (void);
|
||||
static char HelpHandler (void);
|
||||
|
||||
/* Forwards for other functions */
|
||||
static void DisplayPrompt (char* s);
|
||||
static void DisplayPrompt (const char* s);
|
||||
static void SingleStep (char StepInto);
|
||||
static void RedrawStatic (char Frame);
|
||||
static void Redraw (char Frame);
|
||||
@ -166,7 +166,7 @@ extern unsigned DbgHI; /* High 16 bit of primary reg */
|
||||
typedef struct {
|
||||
unsigned char x;
|
||||
unsigned char y;
|
||||
char* text;
|
||||
const char* text;
|
||||
} TextDesc;
|
||||
|
||||
/* Window descriptor */
|
||||
@ -181,13 +181,13 @@ typedef struct {
|
||||
unsigned char fd_visible; /* Is the window currently visible? */
|
||||
char (*fd_func) (void); /* Handler function */
|
||||
unsigned char fd_textcount; /* Number of text lines to print */
|
||||
TextDesc* fd_text; /* Static text in the window */
|
||||
const TextDesc* fd_text; /* Static text in the window */
|
||||
} FrameDesc;
|
||||
|
||||
|
||||
|
||||
/* Texts for the windows */
|
||||
static TextDesc RegText [] = {
|
||||
static const TextDesc RegText [] = {
|
||||
{ 1, 0, "PC" },
|
||||
{ 1, 1, "SR" },
|
||||
{ 1, 2, "A" },
|
||||
@ -197,7 +197,7 @@ static TextDesc RegText [] = {
|
||||
{ 1, 6, "CS" },
|
||||
{ 1, 7, "HI" }
|
||||
};
|
||||
static TextDesc HelpText [] = {
|
||||
static const TextDesc HelpText [] = {
|
||||
{ 1, 0, "F1, ? Help" },
|
||||
{ 1, 1, "F2, t Toggle breakpoint" },
|
||||
{ 1, 2, "F3, u Run until subroutine returns" },
|
||||
@ -220,7 +220,7 @@ static TextDesc HelpText [] = {
|
||||
|
||||
|
||||
/* Window data */
|
||||
static FrameDesc AsmFrame = {
|
||||
static const FrameDesc AsmFrame = {
|
||||
CH_ULCORNER, CH_TTEE, CH_LTEE, CH_CROSS,
|
||||
0, 0, MAX_X - 10, 15,
|
||||
MAX_X - 11, 14,
|
||||
@ -228,7 +228,7 @@ static FrameDesc AsmFrame = {
|
||||
AsmHandler,
|
||||
0, 0
|
||||
};
|
||||
static FrameDesc RegFrame = {
|
||||
static const FrameDesc RegFrame = {
|
||||
CH_TTEE, CH_URCORNER, CH_LTEE, CH_RTEE,
|
||||
MAX_X - 10, 0, MAX_X - 1, 9,
|
||||
8, 8,
|
||||
@ -236,7 +236,7 @@ static FrameDesc RegFrame = {
|
||||
RegHandler,
|
||||
sizeof (RegText) / sizeof (RegText [0]), RegText
|
||||
};
|
||||
static FrameDesc StackFrame = {
|
||||
static const FrameDesc StackFrame = {
|
||||
CH_LTEE, CH_RTEE, CH_CROSS, CH_RTEE,
|
||||
MAX_X - 10, 9, MAX_X - 1, 15,
|
||||
8, 5,
|
||||
@ -244,7 +244,7 @@ static FrameDesc StackFrame = {
|
||||
StackHandler,
|
||||
0, 0
|
||||
};
|
||||
static FrameDesc CStackFrame = {
|
||||
static const FrameDesc CStackFrame = {
|
||||
CH_CROSS, CH_RTEE, CH_BTEE, CH_LRCORNER,
|
||||
MAX_X - 10, 15, MAX_X - 1, MAX_Y - 1,
|
||||
8, MAX_Y - 17,
|
||||
@ -252,7 +252,7 @@ static FrameDesc CStackFrame = {
|
||||
CStackHandler,
|
||||
0, 0
|
||||
};
|
||||
static FrameDesc DumpFrame = {
|
||||
static const FrameDesc DumpFrame = {
|
||||
CH_LTEE, CH_CROSS, CH_LLCORNER, CH_BTEE,
|
||||
0, 15, MAX_X - 10, MAX_Y-1,
|
||||
MAX_X - 11, MAX_Y - 17,
|
||||
@ -260,7 +260,7 @@ static FrameDesc DumpFrame = {
|
||||
DumpHandler,
|
||||
0, 0
|
||||
};
|
||||
static FrameDesc HelpFrame = {
|
||||
static const FrameDesc HelpFrame = {
|
||||
CH_ULCORNER, CH_URCORNER, CH_LLCORNER, CH_LRCORNER,
|
||||
0, 0, MAX_X - 1, MAX_Y-1,
|
||||
MAX_X - 2, MAX_Y - 2,
|
||||
@ -268,7 +268,7 @@ static FrameDesc HelpFrame = {
|
||||
HelpHandler,
|
||||
sizeof (HelpText) / sizeof (HelpText [0]), HelpText
|
||||
};
|
||||
static FrameDesc* Frames [] = {
|
||||
static const FrameDesc* const Frames [] = {
|
||||
&AsmFrame,
|
||||
&RegFrame,
|
||||
&StackFrame,
|
||||
@ -297,7 +297,7 @@ static unsigned char StackAddr; /* Start address of output */
|
||||
|
||||
|
||||
/* Prompt line data */
|
||||
static char* ActivePrompt = 0; /* Last prompt line displayed */
|
||||
static const char* ActivePrompt = 0; /* Last prompt line displayed */
|
||||
static char PromptColor; /* Color behind prompt */
|
||||
static char PromptLength; /* Length of current prompt string */
|
||||
|
||||
@ -346,10 +346,10 @@ BreakPoint* DbgIsBreak (unsigned Addr);
|
||||
|
||||
|
||||
|
||||
static void DrawFrame (register FrameDesc* F, char Active)
|
||||
static void DrawFrame (register const FrameDesc* F, char Active)
|
||||
/* Draw one window frame */
|
||||
{
|
||||
TextDesc* T;
|
||||
const TextDesc* T;
|
||||
unsigned char Count;
|
||||
unsigned char tl, tr, bl, br;
|
||||
unsigned char x1, y1, width;
|
||||
@ -410,7 +410,7 @@ static void DrawFrames (void)
|
||||
/* Draw all frames */
|
||||
{
|
||||
unsigned char I;
|
||||
FrameDesc* F;
|
||||
const FrameDesc* F;
|
||||
|
||||
/* Build the frame layout of the screen */
|
||||
for (I = 0; I < sizeof (Frames) / sizeof (Frames [0]); ++I) {
|
||||
@ -427,7 +427,7 @@ static void ActivateFrame (int Num, unsigned char Clear)
|
||||
/* Activate a new frame, deactivate the old one */
|
||||
{
|
||||
unsigned char y;
|
||||
register FrameDesc* F;
|
||||
register const FrameDesc* F;
|
||||
|
||||
if (ActiveFrame != Num) {
|
||||
|
||||
@ -462,7 +462,7 @@ static void ActivateFrame (int Num, unsigned char Clear)
|
||||
|
||||
|
||||
|
||||
static void DisplayPrompt (char* s)
|
||||
static void DisplayPrompt (const char* s)
|
||||
/* Display a prompt */
|
||||
{
|
||||
unsigned char OldColor;
|
||||
@ -626,11 +626,11 @@ static char InputHex (char* Prompt, unsigned* Val)
|
||||
|
||||
|
||||
|
||||
static void ErrorPrompt (char* Msg)
|
||||
static void ErrorPrompt (const char* Msg)
|
||||
/* Display an error message and wait for a key */
|
||||
{
|
||||
/* Save the current prompt */
|
||||
char* OldPrompt = ActivePrompt;
|
||||
const char* OldPrompt = ActivePrompt;
|
||||
|
||||
/* Display the new one */
|
||||
DisplayPrompt (Msg);
|
||||
|
@ -9,7 +9,7 @@
|
||||
.include "extzp.inc"
|
||||
|
||||
gotoxy:
|
||||
jsr popa ; Get X
|
||||
jsr popa ; Get Y
|
||||
|
||||
_gotoxy:
|
||||
sta CURS_Y ; Set Y
|
||||
@ -20,6 +20,4 @@ _gotoxy:
|
||||
;-------------------------------------------------------------------------------
|
||||
; force the init constructor to be imported
|
||||
|
||||
.import initconio
|
||||
conio_init = initconio
|
||||
|
||||
.forceimport initconio
|
||||
|
@ -24,17 +24,6 @@
|
||||
|
||||
.addr $0000
|
||||
|
||||
; Button state masks (8 values)
|
||||
|
||||
.byte $01 ; JOY_UP
|
||||
.byte $02 ; JOY_DOWN
|
||||
.byte $04 ; JOY_LEFT
|
||||
.byte $08 ; JOY_RIGHT
|
||||
.byte $10 ; JOY_FIRE_A
|
||||
.byte $20 ; JOY_FIRE_B
|
||||
.byte $80 ; JOY_SELECT
|
||||
.byte $40 ; JOY_START
|
||||
|
||||
; Jump table.
|
||||
|
||||
.addr INSTALL
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user