diff --git a/README.md b/README.md index fa8c4df60..6704eec9b 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ including - newer PET machines (not 2001). - the Apple ]\[+ and successors. - the Atari 8 bit machines. +- the Atari 2600 console. - the Atari 5200 console. - GEOS for the C64, C128 and Apple //e. - the Bit Corporation Gamate console. diff --git a/asminc/accelerator.inc b/asminc/accelerator.inc new file mode 100644 index 000000000..23a9686c7 --- /dev/null +++ b/asminc/accelerator.inc @@ -0,0 +1,80 @@ +; +; Accelerator definitions. +; + +; --------------------------------------------------------------------------- +; Speed definitions for all accelerator, to be used as input for the 'set' +; functions. + + +SPEED_SLOW = $00 +SPEED_FAST = $FF + +SPEED_1X = SPEED_SLOW +SPEED_2X = 2 - 1 +SPEED_3X = 3 - 1 +SPEED_4X = 4 - 1 +SPEED_5X = 5 - 1 +SPEED_6X = 6 - 1 +SPEED_7X = 7 - 1 +SPEED_8X = 8 - 1 +SPEED_10X = 10 - 1 +SPEED_12X = 12 - 1 +SPEED_16X = 16 - 1 +SPEED_20X = 20 - 1 + + +; --------------------------------------------------------------------------- +; C64/C128 Super CPU cartridge + +SuperCPU_Slow := $D07A +SuperCPU_Fast := $D07B +SuperCPU_Speed_Mode := $D0B8 +SuperCPU_Detect := $D0BC + + +; --------------------------------------------------------------------------- +; C64DTV + +C64DTV_Extended_Regs := $D03F + +C64DTV_Slow = $00 +C64DTV_Fast = $03 + + +; --------------------------------------------------------------------------- +; C128 native and C128 in C64 mode + +C128_VICIIE_CLK := $D030 + + +; --------------------------------------------------------------------------- +; C64 Chameleon cartridge + +CHAMELEON_CFGTUR := $D0F3 +CHAMELEON_CFGENA := $D0FE + +CHAMELEON_ENABLE_REGS = $2A +CHAMELEON_DISABLE_REGS = $FF + +CHAMELEON_CFGTUR_LIMIT_1MHZ = %00001100 +CHAMELEON_CFGTUR_LIMIT_NONE = %10000000 + + +; --------------------------------------------------------------------------- +; C65/C64DX in C64 mode + +C65_VICIII_KEY := $D02F +C65_VICIII_CTRL_B := $D031 + +C65_VICIII_UNLOCK_1 = $A5 +C65_VICIII_UNLOCK_2 = $96 + + +; --------------------------------------------------------------------------- +; C64 Turbo Master cartridge + +TURBOMASTER_DETECT := $BF53 + +TURBOMASTER_SPEED_REG := $00 + diff --git a/asminc/atmos.inc b/asminc/atmos.inc index 4c3c442fa..8edcf7dc2 100644 --- a/asminc/atmos.inc +++ b/asminc/atmos.inc @@ -104,8 +104,14 @@ PRINT := $F77C ; Sound Effects PING := $FA9F +PING1 := $FA85 SHOOT := $FAB5 +SHOOT1 := $FA9B EXPLODE := $FACB +EXPLODE1 := $FAB1 ZAP := $FAE1 +ZAP1 := $FAC7 TICK := $FB14 +TICK1 := $FAFA TOCK := $FB2A +TOCK1 := $FB10 diff --git a/asminc/c128.inc b/asminc/c128.inc index 9e9acc5a8..45ac3935b 100644 --- a/asminc/c128.inc +++ b/asminc/c128.inc @@ -15,7 +15,7 @@ FNAM := $BB ; Address of filename FNAM_BANK := $C7 ; Bank for filename KEY_COUNT := $D0 ; Number of keys in input buffer FKEY_COUNT := $D1 ; Characters for function key -MODE := $D7 ; 40/80 column mode flag +MODE := $D7 ; 40-/80-column mode (bit 7: 80 columns) CURS_X := $EC ; Cursor column CURS_Y := $EB ; Cursor row SCREEN_PTR := $E0 ; Pointer to current char in text screen @@ -167,34 +167,46 @@ SID_Read3 := $D41C ; --------------------------------------------------------------------------- ; I/O: VDC (128 only) -VDC_INDEX := $D600 -VDC_DATA := $D601 +VDC_INDEX := $D600 ; register address port +VDC_DATA := $D601 ; data port + +; Registers +VDC_DATA_HI = 18 ; video RAM address (big endian) +VDC_DATA_LO = 19 +VDC_CSET = 28 +VDC_RAM_RW = 31 ; RAM port ; --------------------------------------------------------------------------- -; I/O: CIAs +; I/O: Complex Interface Adapters CIA1 := $DC00 -CIA1_PRA := $DC00 -CIA1_PRB := $DC01 -CIA1_DDRA := $DC02 -CIA1_DDRB := $DC03 -CIA1_TOD10 := $DC08 -CIA1_TODSEC := $DC09 -CIA1_TODMIN := $DC0A -CIA1_TODHR := $DC0B -CIA1_ICR := $DC0D -CIA1_CRA := $DC0E -CIA1_CRB := $DC0F +CIA1_PRA := $DC00 ; Port A +CIA1_PRB := $DC01 ; Port B +CIA1_DDRA := $DC02 ; Data direction register for port A +CIA1_DDRB := $DC03 ; Data direction register for port B +CIA1_TA := $DC04 ; 16-bit timer A +CIA1_TB := $DC06 ; 16-bit timer B +CIA1_TOD10 := $DC08 ; Time-of-day tenths of a second +CIA1_TODSEC := $DC09 ; Time-of-day seconds +CIA1_TODMIN := $DC0A ; Time-of-day minutes +CIA1_TODHR := $DC0B ; Time-of-day hours +CIA1_SDR := $DC0C ; Serial data register +CIA1_ICR := $DC0D ; Interrupt control register +CIA1_CRA := $DC0E ; Control register for timer A +CIA1_CRB := $DC0F ; Control register for timer B CIA2 := $DD00 CIA2_PRA := $DD00 CIA2_PRB := $DD01 CIA2_DDRA := $DD02 CIA2_DDRB := $DD03 +CIA2_TA := $DD04 +CIA2_TB := $DD06 CIA2_TOD10 := $DD08 CIA2_TODSEC := $DD09 CIA2_TODMIN := $DD0A CIA2_TODHR := $DD0B +CIA2_SDR := $DD0C CIA2_ICR := $DD0D CIA2_CRA := $DD0E CIA2_CRB := $DD0F diff --git a/asminc/c64.inc b/asminc/c64.inc index 00b66a64f..c12f8e64b 100644 --- a/asminc/c64.inc +++ b/asminc/c64.inc @@ -165,30 +165,36 @@ VDC_INDEX := $D600 VDC_DATA := $D601 ; --------------------------------------------------------------------------- -; I/O: CIAs +; I/O: Complex Interface Adapters CIA1 := $DC00 -CIA1_PRA := $DC00 -CIA1_PRB := $DC01 -CIA1_DDRA := $DC02 -CIA1_DDRB := $DC03 -CIA1_TOD10 := $DC08 -CIA1_TODSEC := $DC09 -CIA1_TODMIN := $DC0A -CIA1_TODHR := $DC0B -CIA1_ICR := $DC0D -CIA1_CRA := $DC0E -CIA1_CRB := $DC0F +CIA1_PRA := $DC00 ; Port A +CIA1_PRB := $DC01 ; Port B +CIA1_DDRA := $DC02 ; Data direction register for port A +CIA1_DDRB := $DC03 ; Data direction register for port B +CIA1_TA := $DC04 ; 16-bit timer A +CIA1_TB := $DC06 ; 16-bit timer B +CIA1_TOD10 := $DC08 ; Time-of-day tenths of a second +CIA1_TODSEC := $DC09 ; Time-of-day seconds +CIA1_TODMIN := $DC0A ; Time-of-day minutes +CIA1_TODHR := $DC0B ; Time-of-day hours +CIA1_SDR := $DC0C ; Serial data register +CIA1_ICR := $DC0D ; Interrupt control register +CIA1_CRA := $DC0E ; Control register for timer A +CIA1_CRB := $DC0F ; Control register for timer B CIA2 := $DD00 CIA2_PRA := $DD00 CIA2_PRB := $DD01 CIA2_DDRA := $DD02 CIA2_DDRB := $DD03 +CIA2_TA := $DD04 +CIA2_TB := $DD06 CIA2_TOD10 := $DD08 CIA2_TODSEC := $DD09 CIA2_TODMIN := $DD0A CIA2_TODHR := $DD0B +CIA2_SDR := $DD0C CIA2_ICR := $DD0D CIA2_CRA := $DD0E CIA2_CRB := $DD0F diff --git a/asminc/joy-kernel.inc b/asminc/joy-kernel.inc index ba969da1d..ef729fe3c 100644 --- a/asminc/joy-kernel.inc +++ b/asminc/joy-kernel.inc @@ -48,14 +48,13 @@ UNINSTALL .addr ; UNINSTALL routine COUNT .addr ; COUNT routine READ .addr ; READ routine - IRQ .addr ; IRQ routine .endstruct .endstruct ;------------------------------------------------------------------------------ ; The JOY API version, stored in JOY_HDR::VERSION -JOY_API_VERSION = $03 +JOY_API_VERSION = $05 ;------------------------------------------------------------------------------ ; Variables diff --git a/asminc/opcodes.inc b/asminc/opcodes.inc index 96cdefb65..aa7a65f00 100644 --- a/asminc/opcodes.inc +++ b/asminc/opcodes.inc @@ -241,12 +241,11 @@ OPC_BIT_abx = $3C ; OPC_NOP = $44 ; doublet ; OPC_NOP = $4B ; doublet -OPC_EOR_izp = $52 +OPC_EOR_izp = $52 ; OPC_NOP = $53 ; doublet ; OPC_NOP = $54 ; doublet ; OPC_NOP = $5A ; doublet ; OPC_NOP = $5B ; doublet -OPC_EOR_abx = $5C ; OPC_NOP = $62 ; doublet ; OPC_NOP = $63 ; doublet diff --git a/asminc/pet.inc b/asminc/pet.inc index 43d52a5d5..d165bb336 100644 --- a/asminc/pet.inc +++ b/asminc/pet.inc @@ -61,8 +61,22 @@ NMIVec := $0094 ; --------------------------------------------------------------------------- ; I/O: 6522 VIA2 -VIA := $E840 -VIA_PRB := $E840 -VIA_PRA := $E841 -VIA_DDRB := $E842 -VIA_DDRA := $E843 +VIA := $E840 ; VIA base address +VIA_PB := VIA+$0 ; Port register B +VIA_PA1 := VIA+$1 ; Port register A +VIA_PRB := VIA+$0 ; *** Deprecated *** +VIA_PRA := VIA+$1 ; *** Deprecated *** +VIA_DDRB := VIA+$2 ; Data direction register B +VIA_DDRA := VIA+$3 ; Data direction register A +VIA_T1CL := VIA+$4 ; Timer 1, low byte +VIA_T1CH := VIA+$5 ; Timer 1, high byte +VIA_T1LL := VIA+$6 ; Timer 1 latch, low byte +VIA_T1LH := VIA+$7 ; Timer 1 latch, high byte +VIA_T2CL := VIA+$8 ; Timer 2, low byte +VIA_T2CH := VIA+$9 ; Timer 2, high byte +VIA_SR := VIA+$A ; Shift register +VIA_CR := VIA+$B ; Auxiliary control register +VIA_PCR := VIA+$C ; Peripheral control register +VIA_IFR := VIA+$D ; Interrupt flag register +VIA_IER := VIA+$E ; Interrupt enable register +VIA_PA2 := VIA+$F ; Port register A w/o handshake diff --git a/asminc/plus4.inc b/asminc/plus4.inc index 3b2f08c54..5ea4dcf88 100644 --- a/asminc/plus4.inc +++ b/asminc/plus4.inc @@ -73,6 +73,7 @@ TED_CURSLO := $FF0D TED_V1FRQLO := $FF0E TED_V2FRQLO := $FF0F TED_V2FRQHI := $FF10 +TED_CLK := $FF13 TED_BGCOLOR := $FF15 TED_COLOR1 := $FF16 TED_COLOR2 := $FF17 diff --git a/asminc/telestrat.inc b/asminc/telestrat.inc index 8e6a66bbd..956d31be3 100644 --- a/asminc/telestrat.inc +++ b/asminc/telestrat.inc @@ -1,7 +1,7 @@ ; ; Oric Telemon definition -; Telemon 2.4 & Telemon 3.0 -; For telemon 3.0 check http://orix.oric.org +; Telemon 2.4 & Telemon 3.x +; For telemon 3.x check http://orix.oric.org ; @@ -15,6 +15,15 @@ FUNCTKEY = $A5 FNAME_LEN = 11 ; maximum length of file-name +; --------------------------------------------------------------------------- +; I/O Identifier +; theses identifers are used for channel management +; + +XKBD = $80 ; keyboard +XRSE = $83 ; RS232 in +XSCR = $88 ; screen +XRSS = $90 ; RS232 out ; --------------------------------------------------------------------------- @@ -34,10 +43,7 @@ TR5 := $11 TR6 := $12 TR7 := $13 - - - -PTR_READ_DEST := $2C ; used for XFREAD and XWRITE only in telemon 3.0 +PTR_READ_DEST := $2C ; used for XFREAD and XWRITE only in telemon 3.x HRSX := $46 HRSY := $47 @@ -48,11 +54,43 @@ HRS3 := $51 HRS4 := $53 HRS5 := $55 +HRSFB := $57 +; RS232T +; b0-b3 : speed +; 1111 => 19200 bps (please note that telestrat can't handle this speed without stopping all IRQ except ACIA's one) +; 1100 => 9600 bps (default from telemon) +; 1110 => 4800 bps +; 1010 => 2400 bps +; 1000 => 1200 bps +; 0111 => 600 bps +; 0110 => 300 bps +; 0101 => 150 bps +; 0010 => 75 bps + +; b4 : 0 external clock, 1 internal clock +; b6-b5 : 00 8 bits +; 01 7 bits +; 10 6 bits +; 11 5 bits +; b7 : 0 a stop + +RS232T := $59 + +; RS232C +; b0-b3 : 0 +; b4 : 1 if echo +; b5 : 1 if parity +; b7-b6 : 00 in/out parity odd +; : 01 on/out parity even +; : 10 parity sent, answer not tested +; : 11 SPACE SENT, reception not tested + +RS232C := $5A ; --------------------------------------------------------------------------- ; Low memory - +IRQVec := $02FB ; "fast" interrupt vector @@ -78,7 +116,7 @@ PRA2 .byte ; Port Register A without handshaking .endstruct -.struct VIA2 ; Versatile Interface Adapter +.struct VIA2 ; Versatile Interface Adapter .res $0320 PRB .byte ; Port Register B PRA .byte ; Port Register A @@ -110,33 +148,45 @@ SCREEN := $BB80 ; --------------------------------------------------------------------------- ; ROM entries -; primitives telemon 2.4 +; telemon primitives (2.4 & 3.x) XRD0 = $08 XRDW0 = $0C XWR0 = $10 -XWSTR0 = $14 +XWSTR0 = $14 ; write a string in text mode XTEXT = $19 XHIRES = $1A XFILLM = $1C XMINMA = $1F -XVARS = $24 ; only in TELEMON 3.0, in telemon 2.4, it's XNOMFI ($24) -XFREAD = $27 ; only in TELEMON 3.0 -XOPEN = $30 ; only in TELEMON 3.0 +XVARS = $24 ; only in TELEMON 3.x, in telemon 2.4, it's XNOMFI ($24) +XFREAD = $27 ; only in TELEMON 3.x +XOPEN = $30 ; only in TELEMON 3.x XCOSCR = $34 ; switch off cursor XCSSCR = $35 ; switch on cursor -XCLOSE = $3A ; only in TELEMON 3.0 Close file -XFWRITE = $3B ; only in TELEMON 3.0 write file +XCLOSE = $3A ; only in TELEMON 3.x Close file +XFWRITE = $3B ; only in TELEMON 3.x write file XSONPS = $40 -XOUPS = $42 +XOUPS = $42 ; send Oups sound into PSG XPLAY = $43 XSOUND = $44 XMUSIC = $45 XZAP = $46 XSHOOT = $47 +XMKDIR = $4B ; create a folder. Only available in telemon 3.x +XRM = $4D ; remove a folder or a file. Only available in telemon 3.x +XSOUT = $67 ; send accumulator value (A) to RS232, available in telemon 2.4 & 3.x : if RS232 buffer is full, the Oric Telestrat freezes +XHRSSE = $8C ; set hires position cursor +XDRAWA = $8D ; draw a line +XDRAWR = $8E ; draw a line XCIRCL = $8F XCURSE = $90 +XCURMO = $91 XPAPER = $92 XINK = $93 +XBOX = $94 +XABOX = $95 +XFILL = $96 +XCHAR = $97 +XSCHAR = $98 ; draw a string in hires XEXPLO = $9C XPING = $9D @@ -151,6 +201,7 @@ SCRX := $220 SCRY := $224 ADSCRL := $218 ADSCRH := $21C +HRSPAT := $2AA ; hires pattern : it's used to draw pattern for a line or a circle IRQVECTOR := $2FA diff --git a/asminc/tgi-kernel.inc b/asminc/tgi-kernel.inc index e9f2f6aa9..fba78afff 100644 --- a/asminc/tgi-kernel.inc +++ b/asminc/tgi-kernel.inc @@ -70,14 +70,13 @@ BAR .addr ; BAR routine TEXTSTYLE .addr ; TEXTSTYLE routine OUTTEXT .addr ; OUTTEXT routine - IRQ .addr ; IRQ routine .endstruct .endstruct ;------------------------------------------------------------------------------ ; The TGI API version, stored at TGI_HDR_VERSION -TGI_API_VERSION = $05 +TGI_API_VERSION = $06 ;------------------------------------------------------------------------------ ; Bitmapped tgi driver flags, stored in TGI_HDR::VARS::FLAGS. diff --git a/asminc/vic20.inc b/asminc/vic20.inc index d882eb1ad..6ac7ef35c 100644 --- a/asminc/vic20.inc +++ b/asminc/vic20.inc @@ -66,16 +66,43 @@ VIC_COLOR := $900F ; Border and background color ; --------------------------------------------------------------------------- ; I/O: 6522 VIA1 -VIA1 := $9110 -VIA1_JOY := $9111 -VIA1_DDRB := $9112 -VIA1_DDRA := $9113 +VIA1 := $9110 ; VIA1 base address +VIA1_JOY := VIA1+$0 ; *** Deprecated *** +VIA1_PB := VIA1+$0 ; Port register B +VIA1_PA1 := VIA1+$1 ; Port register A +VIA1_DDRB := VIA1+$2 ; Data direction register B +VIA1_DDRA := VIA1+$3 ; Data direction register A +VIA1_T1CL := VIA1+$4 ; Timer 1, low byte +VIA1_T1CH := VIA1+$5 ; Timer 1, high byte +VIA1_T1LL := VIA1+$6 ; Timer 1 latch, low byte +VIA1_T1LH := VIA1+$7 ; Timer 1 latch, high byte +VIA1_T2CL := VIA1+$8 ; Timer 2, low byte +VIA1_T2CH := VIA1+$9 ; Timer 2, high byte +VIA1_SR := VIA1+$A ; Shift register +VIA1_CR := VIA1+$B ; Auxiliary control register +VIA1_PCR := VIA1+$C ; Peripheral control register +VIA1_IFR := VIA1+$D ; Interrupt flag register +VIA1_IER := VIA1+$E ; Interrupt enable register +VIA1_PA2 := VIA1+$F ; Port register A w/o handshake ; --------------------------------------------------------------------------- ; I/O: 6522 VIA2 -VIA2 := $9120 -VIA2_JOY := $9120 -VIA2_DDRB := $9122 -VIA2_DDRA := $9123 - +VIA2 := $9120 ; VIA2 base address +VIA2_JOY := VIA2+$0 ; *** Deprecated *** +VIA2_PB := VIA2+$0 ; Port register B +VIA2_PA1 := VIA2+$1 ; Port register A +VIA2_DDRB := VIA2+$2 ; Data direction register B +VIA2_DDRA := VIA2+$3 ; Data direction register A +VIA2_T1CL := VIA2+$4 ; Timer 1, low byte +VIA2_T1CH := VIA2+$5 ; Timer 1, high byte +VIA2_T1LL := VIA2+$6 ; Timer 1 latch, low byte +VIA2_T1LH := VIA2+$7 ; Timer 1 latch, high byte +VIA2_T2CL := VIA2+$8 ; Timer 2, low byte +VIA2_T2CH := VIA2+$9 ; Timer 2, high byte +VIA2_SR := VIA2+$A ; Shift register +VIA2_CR := VIA2+$B ; Auxiliary control register +VIA2_PCR := VIA2+$C ; Peripheral control register +VIA2_IFR := VIA2+$D ; Interrupt flag register +VIA2_IER := VIA2+$E ; Interrupt enable register +VIA2_PA2 := VIA2+$F ; Port register A w/o handshake diff --git a/cfg/apple2-asm.cfg b/cfg/apple2-asm.cfg index 8e5abefc5..76bca1b86 100644 --- a/cfg/apple2-asm.cfg +++ b/cfg/apple2-asm.cfg @@ -3,9 +3,12 @@ FEATURES { STARTADDRESS: default = $0803; } +SYMBOLS { + __FILETYPE__: type = weak, value = $0006; # ProDOS file type +} MEMORY { ZP: file = "", start = $0000, size = $00FF; - HEADER: file = %O, start = %S - 4, size = $0004; + HEADER: file = %O, start = %S - $003A, size = $003A; MAIN: file = %O, define = yes, start = %S, size = $C000 - %S; BSS: file = "", start = __MAIN_LAST__, size = $C000 - __MAIN_LAST__; } diff --git a/cfg/apple2-hgr.cfg b/cfg/apple2-hgr.cfg new file mode 100644 index 000000000..3ccf7b6f3 --- /dev/null +++ b/cfg/apple2-hgr.cfg @@ -0,0 +1,49 @@ +# Configuration for programs including a hires screen (with 6KB LOWCODE) + +FEATURES { + STARTADDRESS: default = $0803; +} +SYMBOLS { + __EXEHDR__: type = import; + __FILETYPE__: type = weak, value = $0006; # ProDOS file type + __STACKSIZE__: type = weak, value = $0800; # 2k stack + __HIMEM__: type = weak, value = $9600; # Presumed RAM end + __LCADDR__: type = weak, value = $D400; # Behind quit code + __LCSIZE__: type = weak, value = $0C00; # Rest of bank two +} +MEMORY { + ZP: file = "", define = yes, start = $0080, size = $001A; + HEADER: file = %O, start = %S - $003A, size = $003A; + MAIN: file = %O, define = yes, start = %S, size = __HIMEM__ - %S; + BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__; + LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__; +} +SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + EXEHDR: load = HEADER, type = ro, optional = yes; + STARTUP: load = MAIN, type = ro; + LOWCODE: load = MAIN, type = ro, optional = yes; + HGR: load = MAIN, type = rw, optional = yes, start = $2000; + CODE: load = MAIN, type = ro start = $4000; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = rw; + ONCE: load = MAIN, type = ro, define = yes; + LC: load = MAIN, run = LC, type = ro, optional = yes; + BSS: load = BSS, type = bss, define = yes; +} +FEATURES { + CONDES: type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__, + segment = ONCE; + CONDES: type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__, + segment = RODATA; + CONDES: type = interruptor, + label = __INTERRUPTOR_TABLE__, + count = __INTERRUPTOR_COUNT__, + segment = RODATA, + import = __CALLIRQ__; +} diff --git a/cfg/apple2-overlay.cfg b/cfg/apple2-overlay.cfg index e6a5ae25c..a0b7678c1 100644 --- a/cfg/apple2-overlay.cfg +++ b/cfg/apple2-overlay.cfg @@ -1,10 +1,10 @@ # Configuration for overlay programs (overlays located below main program) -# The overlay files don't include the 4 byte DOS 3.3 header so use AppleCommander like this: -# java -jar ac.jar -cc65 mydisk.dsk myprog bin < myprog -# java -jar ac.jar -p mydisk.dsk myprog.1 bin < myprog.1 -# java -jar ac.jar -p mydisk.dsk myprog.2 bin < myprog.2 -# java -jar ac.jar -p mydisk.dsk myprog.3 bin < myprog.3 +# The overlay files are raw binary files so use AppleCommander like this: +# java -jar ac.jar -as mydisk.dsk myprog < myprog +# java -jar ac.jar -p mydisk.dsk myprog.1 bin < myprog.1 +# java -jar ac.jar -p mydisk.dsk myprog.2 bin < myprog.2 +# java -jar ac.jar -p mydisk.dsk myprog.3 bin < myprog.3 # ... FEATURES { @@ -12,6 +12,7 @@ FEATURES { } SYMBOLS { __EXEHDR__: type = import; + __FILETYPE__: type = weak, value = $0006; # ProDOS file type __STACKSIZE__: type = weak, value = $0800; # 2k stack __HIMEM__: type = weak, value = $9600; # Presumed RAM end __LCADDR__: type = weak, value = $D400; # Behind quit code @@ -20,7 +21,7 @@ SYMBOLS { } MEMORY { ZP: file = "", define = yes, start = $0080, size = $001A; - HEADER: file = %O, start = %S - 4, size = $0004; + HEADER: file = %O, start = %S - $003A, size = $003A; MAIN: file = %O, define = yes, start = %S + __OVERLAYSIZE__, size = __HIMEM__ - __OVERLAYSIZE__ - %S; BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__; LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__; @@ -36,7 +37,7 @@ MEMORY { } SEGMENTS { ZEROPAGE: load = ZP, type = zp; - EXEHDR: load = HEADER, type = ro; + EXEHDR: load = HEADER, type = ro, optional = yes; STARTUP: load = MAIN, type = ro, define = yes; LOWCODE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; diff --git a/cfg/apple2-system.cfg b/cfg/apple2-system.cfg index f4684d9c2..0170feb93 100644 --- a/cfg/apple2-system.cfg +++ b/cfg/apple2-system.cfg @@ -1,18 +1,22 @@ -# Configuration for ProDOS 8 system programs (without the header) +# Configuration for ProDOS 8 system programs (allowing for 3KB in LC) SYMBOLS { + __EXEHDR__: type = import; + __FILETYPE__: type = weak, value = $00FF; # ProDOS file type __STACKSIZE__: type = weak, value = $0800; # 2k stack __LCADDR__: type = weak, value = $D400; # Behind quit code __LCSIZE__: type = weak, value = $0C00; # Rest of bank two } MEMORY { - ZP: file = "", define = yes, start = $0080, size = $001A; - MAIN: file = %O, start = $2000, size = $BF00 - $2000; - BSS: file = "", start = __ONCE_RUN__, size = $BF00 - __STACKSIZE__ - __ONCE_RUN__; - LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__; + ZP: file = "", define = yes, start = $0080, size = $001A; + HEADER: file = %O, start = $2000 - $003A, size = $003A; + MAIN: file = %O, define = yes, start = $2000, size = $BF00 - $2000; + BSS: file = "", start = __ONCE_RUN__, size = $BF00 - __STACKSIZE__ - __ONCE_RUN__; + LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; + EXEHDR: load = HEADER, type = ro, optional = yes; STARTUP: load = MAIN, type = ro; LOWCODE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; diff --git a/cfg/apple2.cfg b/cfg/apple2.cfg index eba2a0e66..a6809cf89 100644 --- a/cfg/apple2.cfg +++ b/cfg/apple2.cfg @@ -5,6 +5,7 @@ FEATURES { } SYMBOLS { __EXEHDR__: type = import; + __FILETYPE__: type = weak, value = $0006; # ProDOS file type __STACKSIZE__: type = weak, value = $0800; # 2k stack __HIMEM__: type = weak, value = $9600; # Presumed RAM end __LCADDR__: type = weak, value = $D400; # Behind quit code @@ -12,14 +13,14 @@ SYMBOLS { } MEMORY { ZP: file = "", define = yes, start = $0080, size = $001A; - HEADER: file = %O, start = %S - 4, size = $0004; + HEADER: file = %O, start = %S - $003A, size = $003A; MAIN: file = %O, define = yes, start = %S, size = __HIMEM__ - %S; BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__; LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; - EXEHDR: load = HEADER, type = ro; + EXEHDR: load = HEADER, type = ro, optional = yes; STARTUP: load = MAIN, type = ro; LOWCODE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; diff --git a/cfg/apple2enh-asm.cfg b/cfg/apple2enh-asm.cfg index 8e5abefc5..76bca1b86 100644 --- a/cfg/apple2enh-asm.cfg +++ b/cfg/apple2enh-asm.cfg @@ -3,9 +3,12 @@ FEATURES { STARTADDRESS: default = $0803; } +SYMBOLS { + __FILETYPE__: type = weak, value = $0006; # ProDOS file type +} MEMORY { ZP: file = "", start = $0000, size = $00FF; - HEADER: file = %O, start = %S - 4, size = $0004; + HEADER: file = %O, start = %S - $003A, size = $003A; MAIN: file = %O, define = yes, start = %S, size = $C000 - %S; BSS: file = "", start = __MAIN_LAST__, size = $C000 - __MAIN_LAST__; } diff --git a/cfg/apple2enh-hgr.cfg b/cfg/apple2enh-hgr.cfg new file mode 100644 index 000000000..3ccf7b6f3 --- /dev/null +++ b/cfg/apple2enh-hgr.cfg @@ -0,0 +1,49 @@ +# Configuration for programs including a hires screen (with 6KB LOWCODE) + +FEATURES { + STARTADDRESS: default = $0803; +} +SYMBOLS { + __EXEHDR__: type = import; + __FILETYPE__: type = weak, value = $0006; # ProDOS file type + __STACKSIZE__: type = weak, value = $0800; # 2k stack + __HIMEM__: type = weak, value = $9600; # Presumed RAM end + __LCADDR__: type = weak, value = $D400; # Behind quit code + __LCSIZE__: type = weak, value = $0C00; # Rest of bank two +} +MEMORY { + ZP: file = "", define = yes, start = $0080, size = $001A; + HEADER: file = %O, start = %S - $003A, size = $003A; + MAIN: file = %O, define = yes, start = %S, size = __HIMEM__ - %S; + BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__; + LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__; +} +SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + EXEHDR: load = HEADER, type = ro, optional = yes; + STARTUP: load = MAIN, type = ro; + LOWCODE: load = MAIN, type = ro, optional = yes; + HGR: load = MAIN, type = rw, optional = yes, start = $2000; + CODE: load = MAIN, type = ro start = $4000; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = rw; + ONCE: load = MAIN, type = ro, define = yes; + LC: load = MAIN, run = LC, type = ro, optional = yes; + BSS: load = BSS, type = bss, define = yes; +} +FEATURES { + CONDES: type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__, + segment = ONCE; + CONDES: type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__, + segment = RODATA; + CONDES: type = interruptor, + label = __INTERRUPTOR_TABLE__, + count = __INTERRUPTOR_COUNT__, + segment = RODATA, + import = __CALLIRQ__; +} diff --git a/cfg/apple2enh-overlay.cfg b/cfg/apple2enh-overlay.cfg index e6a5ae25c..a0b7678c1 100644 --- a/cfg/apple2enh-overlay.cfg +++ b/cfg/apple2enh-overlay.cfg @@ -1,10 +1,10 @@ # Configuration for overlay programs (overlays located below main program) -# The overlay files don't include the 4 byte DOS 3.3 header so use AppleCommander like this: -# java -jar ac.jar -cc65 mydisk.dsk myprog bin < myprog -# java -jar ac.jar -p mydisk.dsk myprog.1 bin < myprog.1 -# java -jar ac.jar -p mydisk.dsk myprog.2 bin < myprog.2 -# java -jar ac.jar -p mydisk.dsk myprog.3 bin < myprog.3 +# The overlay files are raw binary files so use AppleCommander like this: +# java -jar ac.jar -as mydisk.dsk myprog < myprog +# java -jar ac.jar -p mydisk.dsk myprog.1 bin < myprog.1 +# java -jar ac.jar -p mydisk.dsk myprog.2 bin < myprog.2 +# java -jar ac.jar -p mydisk.dsk myprog.3 bin < myprog.3 # ... FEATURES { @@ -12,6 +12,7 @@ FEATURES { } SYMBOLS { __EXEHDR__: type = import; + __FILETYPE__: type = weak, value = $0006; # ProDOS file type __STACKSIZE__: type = weak, value = $0800; # 2k stack __HIMEM__: type = weak, value = $9600; # Presumed RAM end __LCADDR__: type = weak, value = $D400; # Behind quit code @@ -20,7 +21,7 @@ SYMBOLS { } MEMORY { ZP: file = "", define = yes, start = $0080, size = $001A; - HEADER: file = %O, start = %S - 4, size = $0004; + HEADER: file = %O, start = %S - $003A, size = $003A; MAIN: file = %O, define = yes, start = %S + __OVERLAYSIZE__, size = __HIMEM__ - __OVERLAYSIZE__ - %S; BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__; LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__; @@ -36,7 +37,7 @@ MEMORY { } SEGMENTS { ZEROPAGE: load = ZP, type = zp; - EXEHDR: load = HEADER, type = ro; + EXEHDR: load = HEADER, type = ro, optional = yes; STARTUP: load = MAIN, type = ro, define = yes; LOWCODE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; diff --git a/cfg/apple2enh-system.cfg b/cfg/apple2enh-system.cfg index f4684d9c2..0170feb93 100644 --- a/cfg/apple2enh-system.cfg +++ b/cfg/apple2enh-system.cfg @@ -1,18 +1,22 @@ -# Configuration for ProDOS 8 system programs (without the header) +# Configuration for ProDOS 8 system programs (allowing for 3KB in LC) SYMBOLS { + __EXEHDR__: type = import; + __FILETYPE__: type = weak, value = $00FF; # ProDOS file type __STACKSIZE__: type = weak, value = $0800; # 2k stack __LCADDR__: type = weak, value = $D400; # Behind quit code __LCSIZE__: type = weak, value = $0C00; # Rest of bank two } MEMORY { - ZP: file = "", define = yes, start = $0080, size = $001A; - MAIN: file = %O, start = $2000, size = $BF00 - $2000; - BSS: file = "", start = __ONCE_RUN__, size = $BF00 - __STACKSIZE__ - __ONCE_RUN__; - LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__; + ZP: file = "", define = yes, start = $0080, size = $001A; + HEADER: file = %O, start = $2000 - $003A, size = $003A; + MAIN: file = %O, define = yes, start = $2000, size = $BF00 - $2000; + BSS: file = "", start = __ONCE_RUN__, size = $BF00 - __STACKSIZE__ - __ONCE_RUN__; + LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; + EXEHDR: load = HEADER, type = ro, optional = yes; STARTUP: load = MAIN, type = ro; LOWCODE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; diff --git a/cfg/apple2enh.cfg b/cfg/apple2enh.cfg index eba2a0e66..a6809cf89 100644 --- a/cfg/apple2enh.cfg +++ b/cfg/apple2enh.cfg @@ -5,6 +5,7 @@ FEATURES { } SYMBOLS { __EXEHDR__: type = import; + __FILETYPE__: type = weak, value = $0006; # ProDOS file type __STACKSIZE__: type = weak, value = $0800; # 2k stack __HIMEM__: type = weak, value = $9600; # Presumed RAM end __LCADDR__: type = weak, value = $D400; # Behind quit code @@ -12,14 +13,14 @@ SYMBOLS { } MEMORY { ZP: file = "", define = yes, start = $0080, size = $001A; - HEADER: file = %O, start = %S - 4, size = $0004; + HEADER: file = %O, start = %S - $003A, size = $003A; MAIN: file = %O, define = yes, start = %S, size = __HIMEM__ - %S; BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__; LC: file = "", define = yes, start = __LCADDR__, size = __LCSIZE__; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; - EXEHDR: load = HEADER, type = ro; + EXEHDR: load = HEADER, type = ro, optional = yes; STARTUP: load = MAIN, type = ro; LOWCODE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = ro; diff --git a/cfg/atari5200.cfg b/cfg/atari5200.cfg index 3db8765d6..e8f6d44a5 100644 --- a/cfg/atari5200.cfg +++ b/cfg/atari5200.cfg @@ -15,6 +15,7 @@ MEMORY { SEGMENTS { ZEROPAGE: load = ZP, type = zp, optional = yes; EXTZP: load = ZP, type = zp, optional = yes; + DLIST: load = ROM , type = ro, define = yes, optional = yes; STARTUP: load = ROM, type = ro, define = yes, optional = yes; LOWCODE: load = ROM, type = ro, define = yes, optional = yes; ONCE: load = ROM, type = ro, optional = yes; @@ -22,9 +23,9 @@ SEGMENTS { RODATA: load = ROM, type = ro, optional = yes; DATA: load = ROM, run = RAM, type = rw, define = yes, optional = yes; BSS: load = RAM, type = bss, define = yes, optional = yes; - CARTNAME: load = CARTNAME, type = ro, define = yes; - CARTYEAR: load = CARTYEAR, type = ro, define = yes; - CARTENTRY: load = CARTENTRY, type = ro, define = yes; + CARTNAME: load = CARTNAME, type = ro; + CARTYEAR: load = CARTYEAR, type = ro; + CARTENTRY: load = CARTENTRY, type = ro; } FEATURES { CONDES: type = constructor, diff --git a/cfg/c16-32k.cfg b/cfg/c16-32k.cfg new file mode 100644 index 000000000..b67c66b96 --- /dev/null +++ b/cfg/c16-32k.cfg @@ -0,0 +1,39 @@ +SYMBOLS { + __LOADADDR__: type = import; + __EXEHDR__: type = import; + __STACKSIZE__: type = weak, value = $0800; # 2k stack +} +MEMORY { + ZP: file = "", define = yes, start = $0002, size = $001A; + LOADADDR: file = %O, start = $0FFF, size = $0002; + HEADER: file = %O, start = $1001, size = $000C; + MAIN: file = %O, start = $100D, size = $6FF3 - __STACKSIZE__; +} +SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + LOADADDR: load = LOADADDR, type = ro; + EXEHDR: load = HEADER, type = ro; + STARTUP: load = MAIN, type = ro; + LOWCODE: load = MAIN, type = ro, optional = yes; + ONCE: load = MAIN, type = ro, optional = yes; + CODE: load = MAIN, type = ro; + RODATA: load = MAIN, type = ro; + DATA: load = MAIN, type = rw; + INIT: load = MAIN, type = bss; + BSS: load = MAIN, type = bss, define = yes; +} +FEATURES { + CONDES: type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__, + segment = ONCE; + CONDES: type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__, + segment = RODATA; + CONDES: type = interruptor, + label = __INTERRUPTOR_TABLE__, + count = __INTERRUPTOR_COUNT__, + segment = RODATA, + import = __CALLIRQ__; +} diff --git a/cfg/c16.cfg b/cfg/c16.cfg index b67c66b96..41545d473 100644 --- a/cfg/c16.cfg +++ b/cfg/c16.cfg @@ -1,13 +1,13 @@ SYMBOLS { __LOADADDR__: type = import; __EXEHDR__: type = import; - __STACKSIZE__: type = weak, value = $0800; # 2k stack + __STACKSIZE__: type = weak, value = $0400; # 1k stack } MEMORY { ZP: file = "", define = yes, start = $0002, size = $001A; LOADADDR: file = %O, start = $0FFF, size = $0002; HEADER: file = %O, start = $1001, size = $000C; - MAIN: file = %O, start = $100D, size = $6FF3 - __STACKSIZE__; + MAIN: file = %O, start = $100D, size = $2FF3 - __STACKSIZE__; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; diff --git a/cfg/creativision.cfg b/cfg/creativision.cfg index 9e4ecd8ce..2eb9ac427 100644 --- a/cfg/creativision.cfg +++ b/cfg/creativision.cfg @@ -1,9 +1,9 @@ SYMBOLS { - __STACKSIZE__: type = weak, value = $0180; + __STACKSIZE__: type = weak, value = $0040; } MEMORY { ZP: file = "", define = yes, start = $0020, size = $00E0; - RAM: file = "", define = yes, start = $01FA, size = $0206; + RAM: file = "", define = yes, start = $01FA, size = $0206 - __STACKSIZE__; ROM: file = %O, define = yes, start = $B000, size = $1000, fill = yes, fillval = $FF; } SEGMENTS { diff --git a/cfg/none.cfg b/cfg/none.cfg index 6742da7c8..cedd2d839 100644 --- a/cfg/none.cfg +++ b/cfg/none.cfg @@ -1,12 +1,18 @@ +FEATURES { + STARTADDRESS: default = $1000; +} SYMBOLS { - __STACKSIZE__: type = weak, value = $0800; # 2k stack + __STACKSIZE__: type = weak, value = $0800; # 2k stack + __STACKSTART__: type = weak, value = $8000; + __ZPSTART__: type = weak, value = $0080; } MEMORY { - ZP: file = "", define = yes, start = $0000, size = $0001F; - MAIN: file = %O, start = %S, size = $10000 - __STACKSIZE__; + ZP: file = "", define = yes, start = __ZPSTART__, size = $001F; + MAIN: file = %O, start = %S, size = __STACKSTART__ - __STACKSIZE__ - %S; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; + STARTUP: load = MAIN, type = ro, optional = yes; LOWCODE: load = MAIN, type = ro, optional = yes; ONCE: load = MAIN, type = ro, optional = yes; CODE: load = MAIN, type = rw; diff --git a/cfg/pce.cfg b/cfg/pce.cfg index 6332f8eff..77f8c5c97 100644 --- a/cfg/pce.cfg +++ b/cfg/pce.cfg @@ -1,34 +1,29 @@ -# linker config to produce simple NEC PC-Engine cartridge (.pce) - +# linker config. to produce a NEC PC-Engine 8K, 16K, or 32K image (.bin) SYMBOLS { + __CARTSIZE__: type = weak, value = $2000; # $2000, $4000, or $8000 __STACKSIZE__: type = weak, value = $0300; # 3 pages stack } - MEMORY { - # FIXME: is this correct? the first 3? bytes cant be used? - ZP: file = "", start = $0003, size = $00FD, type = rw, define = yes; - - # reset-bank and hardware vectors - ROM0: file = %O, start = $E000, size = $1FF6, fill = yes, define = yes; - ROMV: file = %O, start = $FFF6, size = $000A, fill = yes; - - # first RAM page (also contains stack and zeropage) - RAM: file = "", start = $2200, size = $1e00, define = yes; + ZP: file = "", start = $0000, size = $0100, define = yes; + # RAM bank + MAIN: file = "", start = $2200, size = $1E00 - __STACKSIZE__, define = yes; + # ROM banks, before swapping, and after mapping + ROM: file = %O, start = $10000 - __CARTSIZE__, size = __CARTSIZE__, fill = yes, fillval = $FF; } - SEGMENTS { - ZEROPAGE: load = ZP, type = zp, define = yes; - EXTZP: load = ZP, type = zp, define = yes, optional = yes; - APPZP: load = ZP, type = zp, define = yes, optional = yes; - STARTUP: load = ROM0, type = ro, define = yes; - ONCE: load = ROM0, type = ro, optional = yes; - CODE: load = ROM0, type = ro, define = yes; - RODATA: load = ROM0, type = ro, define = yes; - DATA: load = ROM0, run = RAM, type = rw, define = yes; - BSS: load = RAM, type = bss, define = yes; - VECTORS: load = ROMV, type = rw, define = yes; + ZEROPAGE: load = ZP, type = zp; + EXTZP: load = ZP, type = zp, optional = yes; + APPZP: load = ZP, type = zp, optional = yes; + DATA: load = ROM, run = MAIN, type = rw, define = yes; + INIT: load = MAIN, type = bss, optional = yes; + BSS: load = MAIN, type = bss, define = yes; + RODATA: load = ROM, type = ro; + CODE: load = ROM, type = ro; + LOWCODE: load = ROM, type = ro, optional = yes; + ONCE: load = ROM, type = ro, optional = yes; + STARTUP: load = ROM, type = ro, start = $FFF6 - $0066; + VECTORS: load = ROM, type = ro, start = $FFF6; } - FEATURES { CONDES: type = constructor, label = __CONSTRUCTOR_TABLE__, diff --git a/cfg/supervision-128k.cfg b/cfg/supervision-128k.cfg index 0304e2c02..a03ab0e1b 100644 --- a/cfg/supervision-128k.cfg +++ b/cfg/supervision-128k.cfg @@ -2,13 +2,13 @@ # for assembler # ld65 config file -# ld65 --config supervision.cfg -o .bin .o +# ld65 --config supervision-128k.cfg -o .bin .o SYMBOLS { __STACKSIZE__: type = weak, value = $0100; # 1 page stack } MEMORY { - RAM: file = "", start = $0000, size = $2000 - __STACKSIZE__; + RAM: file = "", start = $0000, size = $2000 - __STACKSIZE__, define = yes; VRAM: file = "", start = $4000, size = $2000; BANKROM1: file = %O, start = $8000, size = $4000, fill = yes, fillval = $FF; BANKROM2: file = %O, start = $8000, size = $4000, fill = yes, fillval = $FF; diff --git a/cfg/supervision-16k.cfg b/cfg/supervision-16k.cfg index 86c8fface..e0b54be23 100644 --- a/cfg/supervision-16k.cfg +++ b/cfg/supervision-16k.cfg @@ -1,7 +1,7 @@ # supervision 16kbyte cartridge # ld65 config file -# ld65 --config supervision16.cfg -o .bin .o +# ld65 --config supervision-16k.cfg -o .bin .o SYMBOLS { __STACKSIZE__: type = weak, value = $0100; # 1 page stack @@ -9,9 +9,9 @@ SYMBOLS { MEMORY { ZP: file = "", start = $0000, size = $0100; CPUSTACK: file = "", start = $0100, size = $0100; - RAM: file = "", start = $0200, size = $1E00 - __STACKSIZE__; + RAM: file = "", start = $0200, size = $1E00 - __STACKSIZE__, define = yes; VRAM: file = "", start = $4000, size = $2000; - ROM: file = %O, start = $C000, size = $4000, fill = yes, fillval = $ff, define=yes; + ROM: file = %O, start = $C000, size = $4000, fill = yes, fillval = $FF, define = yes; } SEGMENTS { ZEROPAGE: load = ZP, type = zp, define = yes; diff --git a/cfg/supervision-64k.cfg b/cfg/supervision-64k.cfg index 8a7665c30..9d5f15e45 100644 --- a/cfg/supervision-64k.cfg +++ b/cfg/supervision-64k.cfg @@ -2,13 +2,13 @@ # for assembler # ld65 config file -# ld65 --config supervision.cfg -o .bin .o +# ld65 --config supervision-64k.cfg -o .bin .o SYMBOLS { __STACKSIZE__: type = weak, value = $0100; # 1 page stack } MEMORY { - RAM: file = "", start = $0000, size = $2000 - __STACKSIZE__; + RAM: file = "", start = $0000, size = $2000 - __STACKSIZE__, define = yes; VRAM: file = "", start = $4000, size = $2000; BANKROM1: file = %O, start = $8000, size = $4000, fill = yes, fillval = $FF; BANKROM2: file = %O, start = $8000, size = $4000, fill = yes, fillval = $FF; diff --git a/cfg/supervision.cfg b/cfg/supervision.cfg index 2d20e3461..d9f189f2b 100644 --- a/cfg/supervision.cfg +++ b/cfg/supervision.cfg @@ -8,7 +8,7 @@ SYMBOLS { MEMORY { ZP: file = "", start = $0000, size = $0100; CPUSTACK: file = "", start = $0100, size = $0100; - RAM: file = "", start = $0200, size = $1E00 - __STACKSIZE__; + RAM: file = "", start = $0200, size = $1E00 - __STACKSIZE__, define = yes; VRAM: file = "", start = $4000, size = $2000; ROM: file = %O, start = $8000, size = $8000, fill = yes, fillval = $FF, define = yes; } diff --git a/cfg/vic20-32k.cfg b/cfg/vic20-32k.cfg index 28dd661ad..fe53d46ab 100644 --- a/cfg/vic20-32k.cfg +++ b/cfg/vic20-32k.cfg @@ -3,7 +3,7 @@ SYMBOLS { __LOADADDR__: type = import; __EXEHDR__: type = import; - __STACKSIZE__: type = weak, value = $0400; # 1k stack + __STACKSIZE__: type = weak, value = $0800; # 2k stack } MEMORY { ZP: file = "", define = yes, start = $0002, size = $001A; diff --git a/doc/apple2.sgml b/doc/apple2.sgml index 33a878223..eef0eed3d 100644 --- a/doc/apple2.sgml +++ b/doc/apple2.sgml @@ -34,20 +34,14 @@ more information. Binary format

The standard binary file format generated by the linker for the -Apple ][ target is a binary program with a 4 byte DOS 3.3 header -containing the load address and load length. The default load address is -$803. +Apple ][ target is an file. +The default load address is $803. -) includes the option for those programs -omits the DOS 3.3 header. The right AppleCommander option to put system files -without a header on a ProDOS 8 disk image is ) includes the option Memory layout

@@ -121,9 +115,8 @@ Parameters: Default: $803. Use - Default: DOS 3.3 header (address and length). Use + Default: Yes. Use Default: $800. Use + + Default: Yes. Use Default: $800. Use

+ + +Configuration for a program including a hires page. See testcode/lib/apple/hgrtest.c +for an example of such a program. + +Parameters: + + + + + Default: $803. Use + Default: Yes. Use + Default: $800. Use + Default: $9600. Use + Default: $D400. Use + Default: $C00. Use

+ + -Configuration for overlay programs with the up to nine overlays. The overlay files -don't include the DOS 3.3 header. See samples/overlaydemo.c for more +Configuration for an overlay program with up to nine overlays. The overlay files +don't include the AppleSingle header. See samples/overlaydemo.c for more information on overlays. Parameters: @@ -181,9 +211,8 @@ Parameters: Default: $803. Use - Default: DOS 3.3 header (address and length). Use + Default: Yes. Use Default: $800. Use -Configuration for a assembler programs which don't need a special setup. +Configuration for an assembler program that doesn't need a special setup. Parameters: @@ -219,9 +248,8 @@ Parameters: Default: $803. Use - Default: No header. Use + Default: No. Use

@@ -246,7 +274,8 @@ program (i.e. quits to the ProDOS dispatcher). Using LOADER.SYSTEM is as simple as copying it to the ProDOS 8 directory of the program to load under name <program>.SYSTEM as a system program. For -example the program Heap

@@ -435,8 +464,7 @@ BASIC.SYSTEM) there are some limitations for DOS 3.3:

diff --git a/doc/apple2enh.sgml b/doc/apple2enh.sgml index 4f5202543..b40523aba 100644 --- a/doc/apple2enh.sgml +++ b/doc/apple2enh.sgml @@ -34,20 +34,14 @@ more information. Binary format

The standard binary file format generated by the linker for the -enhanced Apple //e target is a binary program with a 4 byte DOS 3.3 header -containing the load address and load length. The default load address is -$803. +enhanced Apple //e target is an file. +The default load address is $803. -) includes the option for those programs -omits the DOS 3.3 header. The right AppleCommander option to put system files -without a header on a ProDOS 8 disk image is ) includes the option Memory layout

@@ -121,9 +115,8 @@ Parameters: Default: $803. Use - Default: DOS 3.3 header (address and length). Use + Default: Yes. Use Default: $800. Use + + Default: Yes. Use Default: $800. Use

+ + +Configuration for a program including a hires page. See testcode/lib/apple/hgrtest.c +for an example of such a program. + +Parameters: + + + + + Default: $803. Use + Default: Yes. Use + Default: $800. Use + Default: $9600. Use + Default: $D400. Use + Default: $C00. Use

+ + -Configuration for overlay programs with the up to nine overlays. The overlay files -don't include the DOS 3.3 header. See samples/overlaydemo.c for more +Configuration for an overlay program with up to nine overlays. The overlay files +don't include the AppleSingle header. See samples/overlaydemo.c for more information on overlays. Parameters: @@ -181,9 +211,8 @@ Parameters: Default: $803. Use - Default: DOS 3.3 header (address and length). Use + Default: Yes. Use Default: $800. Use -Configuration for a assembler programs which don't need a special setup. +Configuration for an assembler program that doesn't need a special setup. Parameters: @@ -219,9 +248,8 @@ Parameters: Default: $803. Use - Default: No header. Use + Default: No. Use

@@ -246,7 +274,8 @@ program (i.e. quits to the ProDOS dispatcher). Using LOADER.SYSTEM is as simple as copying it to the ProDOS 8 directory of the program to load under name <program>.SYSTEM as a system program. For -example the program Heap

@@ -436,8 +465,7 @@ BASIC.SYSTEM) there are some limitations for DOS 3.3:

diff --git a/doc/atari.sgml b/doc/atari.sgml index 6cbff6208..459e8e745 100644 --- a/doc/atari.sgml +++ b/doc/atari.sgml @@ -394,7 +394,7 @@ under different mappings, defining remapped strings works only flawlessly with static array initialization: -#include <atari\_screen\_charmap.h> +#include <atari_screen_charmap.h> char pcScreenMappingString[] = "Hello Atari!"; #include <atari_atascii_charmap.h> diff --git a/doc/atmos.sgml b/doc/atmos.sgml index 68f7f9d65..9e61fbd1c 100644 --- a/doc/atmos.sgml +++ b/doc/atmos.sgml @@ -159,7 +159,10 @@ No extended memory drivers are currently available for the Atmos. - Supports two standard joysticks connected to the P.A.S.E. interface of the Atmos. + Supports two standard joysticks connected to a P.A.S.E. / Altai interface of the Atmos. + + + Supports two standard joysticks connected to an IJK interface of the Atmos.

diff --git a/doc/c128.sgml b/doc/c128.sgml index 460621be0..1bdcf01f5 100644 --- a/doc/c128.sgml +++ b/doc/c128.sgml @@ -85,8 +85,21 @@ url="funcref.html" name="function reference"> for declaration and usage. videomode c64mode -fast -slow + + + +C128-specific accelerator functions

+ +The functions listed below are accelerator functions for the C128. See the for declaration and usage. + + +detect_c128 +detect_scpu +get_c128_speed +get_scpu_speed +set_c128_speed +set_scpu_speed @@ -122,6 +135,19 @@ declaration and usage. +CBM specific CPU functions

+ +Some CPU related functions are available for some of the Commodore +machines. See the for +declaration and usage. + + +fast +slow +isfast + + + Hardware access

The following pseudo variables declared in the - A driver for the CBM REUs. The driver will determine from the connected REU - if it supports 128KB of RAM or more. In the latter case, 256KB are assumed, - but since there are no range checks, the application can use more memory if - it has better knowledge about the hardware than the driver. + A driver for the CBM REUs. The driver will test the connected REU to find + out how much RAM is present. A driver for the VDC memory of the C128, written and contributed by Maciej diff --git a/doc/c16.sgml b/doc/c16.sgml index 1614516b7..27938ff1e 100644 --- a/doc/c16.sgml +++ b/doc/c16.sgml @@ -126,6 +126,18 @@ declaration and usage. +CBM specific CPU functions

+ +Some CPU related functions are available for some of the Commodore +machines. See the for +declaration and usage. + + +fast +slow +isfast + + Hardware access

The following pseudo variables declared in the Commodore 64-specific information for cc65 -2017-01-18 +2018-05-14 An overview over the C64 runtime system as it is implemented for the cc65 C @@ -122,8 +122,8 @@ since the program must be loaded to the BASIC start address. 80 Columns conio driver

The C64 package comes with an alternative software driven 80 columns -module for declaration and usage. +C64-specific accelerator functions

+ +The functions listed below are accelerator functions for the C64. See the for declaration and usage. + + +detect_c128 +detect_c64dtv +detect_c65 +detect_chameleon +detect_scpu +detect_turbomaster +get_c128_speed +get_c64dtv_speed +get_c65_speed +get_chameleon_speed +get_scpu_speed +get_turbomaster_speed +set_c128_speed +set_c64dtv_speed +set_c65_speed +set_chameleon_speed +set_scpu_speed +set_turbomaster_speed + + + CBM-specific functions

Some functions are available for all (or at least most) of the Commodore @@ -291,7 +318,7 @@ Note that the graphics drivers are incompatible with the bytes each. Written and contributed by Marco van den Heuvel. - A driver for the hidden RAM below the I/O area and kernal ROM. Supports 48 + A driver for the hidden RAM below the I/O area and kernal ROM. Supports 47 256 byte pages. Please note that this driver is incompatible with any of the graphics drivers, or the soft80 conio driver! @@ -300,10 +327,8 @@ Note that the graphics drivers are incompatible with the Will test the hardware for the available RAM. - A driver for the CBM REUs. The driver will determine from the connected REU - if it supports 128KB of RAM or more. In the latter case, 256KB are assumed, - but since there are no range checks, the application can use more memory if - it has better knowledge about the hardware than the driver. + A driver for the CBM REUs. The driver will test the connected REU to find + out how much RAM is present. A driver for the VDC memory of the C128. Written and contributed by Maciej diff --git a/doc/cc65.sgml b/doc/cc65.sgml index cd94f50ac..11a5937b2 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -407,6 +407,7 @@ Here is a description of all the command line options: sim6502 sim65c02 supervision + telestrat vic20 @@ -941,6 +942,10 @@ The compiler defines several macros at startup: This macro is defined if the target is the Supervision (-t supervision). + __TELESTRAT__ + + This macro is defined if the target is the Telestrat (-t telestrat). + __TIME__ This macro expands to the time of translation of the preprocessing diff --git a/doc/cl65.sgml b/doc/cl65.sgml index 8b3c02cbb..ca5f9d2af 100644 --- a/doc/cl65.sgml +++ b/doc/cl65.sgml @@ -4,7 +4,7 @@ cl65 Users Guide <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline> <url url="mailto:greg.king5@verizon.net" name="Greg King"> -<date>2017-05-24 +<date>2017-10-16 <abstract> cl65 is the compile & link utility for cc65, the 6502 C compiler. It was @@ -69,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 diff --git a/doc/creativision.sgml b/doc/creativision.sgml index 64623b3b2..29653ce0f 100644 --- a/doc/creativision.sgml +++ b/doc/creativision.sgml @@ -4,7 +4,7 @@ <title>VTech Creativision (aka Funvision) specific information for cc65 <author><url url="mailto:polluks+cc65@sdf.lonestar.org" name="Stefan A. Haubenthal"> -<date>2016-04-14 +<date>2017-11-15 <abstract> An overview over the Creativision runtime system as it is implemented for the @@ -31,14 +31,16 @@ more than one platform. Please see the function reference for more information. <sect>Binary format<p> The standard binary output format generated by the linker for the Creativision target -is a 4 kbyte machine language program. It is of course possible to change -this behaviour by using one of the different linker configs. +is a 4 KB ROM image. To create an 8 KB ROM a custom linker script has +to be used. <sect>Memory layout<p> -cc65 generated programs with the default setup run with the I/O area enabled, -which gives a usable memory range of $B000 - $BEFF. -More ROM may need additional bankswitching code. +cc65 generated programs with the default setup are 4 KB in size, +occupying $B000 - $BFFF. Usable memory space for the +user program is $B000 - $BEFF. $BF00 - +$BFFF is reserved for the runtime and cartridge configuration +area. Special locations: @@ -47,11 +49,15 @@ Special locations: The text screen is located at VRAM $1000. <tag/Stack/ - The C runtime stack is located at $3FF and growing downwards. + The C runtime stack is located at $03FF and growing downwards. + + <tag/RAM/ + The available RAM for cc65 programs of an unexpanded Creativision + starts at $01FA and ends at $03FF. <tag/Heap/ - The C heap is located at the end of the program and grows towards the C - runtime stack. + The C heap is located at the end of the program's data area and + grows towards the C runtime stack. </descrip><p> diff --git a/doc/dio.sgml b/doc/dio.sgml index c85992a4a..39aac251c 100644 --- a/doc/dio.sgml +++ b/doc/dio.sgml @@ -25,8 +25,7 @@ released with the <tt>dio_close</tt> function. dhandle_t __fastcall__ dio_open (unsigned char device); </verb></tscreen> -The <tt>device</tt> specifies the device to access, with 0 being the first -device, 1 the second, and so on. +The <tt>device</tt> specifies the device to access. <tscreen><verb> unsigned char __fastcall__ dio_close (dhandle_t handle); diff --git a/doc/funcref.sgml b/doc/funcref.sgml index 1d5ee7c19..f10379c93 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -4,7 +4,7 @@ <title>cc65 function reference <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 +<date>2018-02-07 <abstract> cc65 is a C compiler for 6502 based systems. This function reference describes @@ -65,6 +65,30 @@ function. </itemize> +<sect1><tt/accelerator.h/<label id="accelerator.h"><p> + +<itemize> +<item><ref id="detect_c128" name="detect_c128"> +<item><ref id="detect_c64dtv" name="detect_c64dtv"> +<item><ref id="detect_c65" name="detect_c65"> +<item><ref id="detect_chameleon" name="detect_chameleon"> +<item><ref id="detect_scpu" name="detect_scpu"> +<item><ref id="detect_turbomaster" name="detect_turbomaster"> +<item><ref id="get_c128_speed" name="get_c128_speed"> +<item><ref id="get_c64dtv_speed" name="get_c64dtv_speed"> +<item><ref id="get_c65_speed" name="get_c65_speed"> +<item><ref id="get_chameleon_speed" name="get_chameleon_speed"> +<item><ref id="get_scpu_speed" name="get_scpu_speed"> +<item><ref id="get_turbomaster_speed" name="get_turbomaster_speed"> +<item><ref id="set_c128_speed" name="set_c128_speed"> +<item><ref id="set_c64dtv_speed" name="set_c64dtv_speed"> +<item><ref id="set_c65_speed" name="set_c65_speed"> +<item><ref id="set_chameleon_speed" name="set_chameleon_speed"> +<item><ref id="set_scpu_speed" name="set_scpu_speed"> +<item><ref id="set_turbomaster_speed" name="set_turbomaster_speed"> +</itemize> + + <sect1><tt/apple2.h/<label id="apple2.h"><p> <itemize> @@ -115,24 +139,23 @@ function. <sect1><tt/atmos.h/<label id="atmos.h"><p> <itemize> +<item><ref id="atmos_explode" name="atmos_explode"> <item><ref id="atmos_load" name="atmos_load"> +<item><ref id="atmos_ping" name="atmos_ping"> <item><ref id="atmos_save" name="atmos_save"> -<!-- <item><ref id="atmos_explode" name="atmos_explode"> --> -<!-- <item><ref id="atmos_ping" name="atmos_ping"> --> -<!-- <item><ref id="atmos_shoot" name="atmos_shoot"> --> -<!-- <item><ref id="atmos_tick" name="atmos_tick"> --> -<!-- <item><ref id="atmos_tock" name="atmos_tock"> --> -<!-- <item><ref id="atmos_zap" name="atmos_zap"> --> +<item><ref id="atmos_shoot" name="atmos_shoot"> +<item><ref id="atmos_tick" name="atmos_tick"> +<item><ref id="atmos_tock" name="atmos_tock"> +<item><ref id="atmos_zap" name="atmos_zap"> </itemize> -(incomplete) - <sect1><tt/c128.h/<label id="c128.h"><p> <itemize> <item><ref id="c64mode" name="c64mode"> <item><ref id="fast" name="fast"> +<item><ref id="isfast" name="isfast"> <item><ref id="slow" name="slow"> <item><ref id="toggle_videomode" name="toggle_videomode"> <item><ref id="videomode" name="videomode"> @@ -141,6 +164,12 @@ function. <sect1><tt/c16.h/<label id="c16.h"><p> +<itemize> +<item><ref id="fast" name="fast"> +<item><ref id="isfast" name="isfast"> +<item><ref id="slow" name="slow"> +</itemize> + (incomplete) @@ -184,6 +213,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="waitvsync" name="waitvsync"> <item><ref id="kbrepeat" name="kbrepeat"> </itemize> @@ -239,6 +269,10 @@ function. <item><ref id="chline" name="chline"> <item><ref id="chlinexy" name="chlinexy"> <item><ref id="clrscr" name="clrscr"> +<item><ref id="cpeekc" name="cpeekc"> +<item><ref id="cpeekcolor" name="cpeekcolor"> +<item><ref id="cpeekrevers" name="cpeekrevers"> +<item><ref id="cpeeks" name="cpeeks"> <item><ref id="cprintf" name="cprintf"> <item><ref id="cputc" name="cputc"> <item><ref id="cputcxy" name="cputcxy"> @@ -290,6 +324,16 @@ function. (incomplete) +<sect1><tt/device.h/<label id="device.h"><p> + +<itemize> +<item><ref id="getcurrentdevice" name="getcurrentdevice"> +<item><ref id="getdevicedir" name="getdevicedir"> +<item><ref id="getfirstdevice" name="getfirstdevice"> +<item><ref id="getnextdevice" name="getnextdevice"> +</itemize> + + <sect1><tt/dio.h/<label id="dio.h"><p> <url url="dio.html" name="Low-level disk I/O API">. @@ -310,8 +354,6 @@ function. <item><ref id="telldir" name="telldir"> </itemize> -(incomplete) - <sect1><tt/em.h/<label id="em.h"><p> @@ -352,17 +394,17 @@ function. <sect1><tt/gamate.h/<label id="gamate.h"><p> -<!-- <itemize> --> +<itemize> <!-- <item><ref id="get_tv" name="get_tv"> --> -<!-- <item><ref id="waitvblank" name="waitvblank"> --> -<!-- </itemize> --> +<item><ref id="waitvsync" name="waitvsync"> +</itemize> (incomplete) <sect1><tt/geos.h/<label id="geos.h"><p> -(incomplete) +<url url="geos.html" name="GEOS API">. <sect1><tt/joystick.h/<label id="joystick.h"><p> @@ -437,10 +479,10 @@ function. <sect1><tt/nes.h/<label id="nes.h"><p> -<!-- <itemize> --> +<itemize> <!-- <item><ref id="get_tv" name="get_tv"> --> -<!-- <item><ref id="waitvsync" name="waitvsync"> --> -<!-- </itemize> --> +<item><ref id="waitvsync" name="waitvsync"> +</itemize> (incomplete) @@ -455,10 +497,10 @@ It does not declare any functions. <sect1><tt/pce.h/<label id="pce.h"><p> -<!-- <itemize> --> +<itemize> <!-- <item><ref id="get_tv" name="get_tv"> --> -<!-- <item><ref id="waitvblank" name="waitvblank"> --> -<!-- </itemize> --> +<item><ref id="waitvsync" name="waitvsync"> +</itemize> (incomplete) @@ -490,6 +532,12 @@ It does not declare any functions. <sect1><tt/plus4.h/<label id="plus4.h"><p> +<itemize> +<item><ref id="fast" name="fast"> +<item><ref id="isfast" name="isfast"> +<item><ref id="slow" name="slow"> +</itemize> + (incomplete) @@ -658,9 +706,11 @@ communication. <item><ref id="strlen" name="strlen"> <item><ref id="strlower" name="strlower"> <item><ref id="strlwr" name="strlwr"> +<item><ref id="strncasecmp" name="strncasecmp"> <item><ref id="strncat" name="strncat"> <item><ref id="strncmp" name="strncmp"> <item><ref id="strncpy" name="strncpy"> +<item><ref id="strnicmp" name="strnicmp"> <item><ref id="strqtok" name="strqtok"> <item><ref id="strrchr" name="strrchr"> <item><ref id="strspn" name="strspn"> @@ -671,57 +721,25 @@ communication. <item><ref id="strupr" name="strupr"> </itemize> + +<sect1><tt/telestrat.h/<label id="telestrat.h"><p> + +<itemize> +<item><ref id="atmos_explode" name="explode"> +<item><ref id="atmos_ping" name="ping"> +<item><ref id="atmos_shoot" name="shoot"> +<item><ref id="atmos_zap" name="zap"> +<!-- <item><ref id="kbdclick1" name="kbdclick1"> --> +<!-- <item><ref id="oups" name="oups"> --> +</itemize> + (incomplete) <sect1><tt/tgi.h/<label id="tgi.h"><p> -<itemize> -<item><ref id="tgi_arc" name="tgi_arc"> -<item><ref id="tgi_bar" name="tgi_bar"> -<item><ref id="tgi_circle" name="tgi_circle"> -<item><ref id="tgi_clear" name="tgi_clear"> -<item><ref id="tgi_done" name="tgi_done"> -<item><ref id="tgi_ellipse" name="tgi_ellipse"> -<item><ref id="tgi_free_vectorfont" name="tgi_free_vectorfont"> -<item><ref id="tgi_getaspectratio" name="tgi_getaspectratio"> -<item><ref id="tgi_getcolor" name="tgi_getcolor"> -<item><ref id="tgi_getcolorcount" name="tgi_getcolorcount"> -<item><ref id="tgi_getdefpalette" name="tgi_getdefpalette"> -<item><ref id="tgi_geterror" name="tgi_geterror"> -<item><ref id="tgi_geterrormsg" name="tgi_geterrormsg"> -<item><ref id="tgi_getmaxcolor" name="tgi_getmaxcolor"> -<item><ref id="tgi_getmaxx" name="tgi_getmaxx"> -<item><ref id="tgi_getmaxy" name="tgi_getmaxy"> -<item><ref id="tgi_getpagecount" name="tgi_getpagecount"> -<item><ref id="tgi_getpalette" name="tgi_getpalette"> -<item><ref id="tgi_getpixel" name="tgi_getpixel"> -<item><ref id="tgi_gettextheight" name="tgi_gettextheight"> -<item><ref id="tgi_gettextwidth" name="tgi_gettextwidth"> -<item><ref id="tgi_getxres" name="tgi_getxres"> -<item><ref id="tgi_getyres" name="tgi_getyres"> -<item><ref id="tgi_gotoxy" name="tgi_gotoxy"> -<item><ref id="tgi_init" name="tgi_init"> -<item><ref id="tgi_install" name="tgi_install"> -<item><ref id="tgi_install_vectorfont" name="tgi_install_vectorfont"> -<item><ref id="tgi_ioctl" name="tgi_ioctl"> -<item><ref id="tgi_line" name="tgi_line"> -<item><ref id="tgi_lineto" name="tgi_lineto"> -<item><ref id="tgi_load_driver" name="tgi_load_driver"> -<item><ref id="tgi_load_vectorfont" name="tgi_load_vectorfont"> -<item><ref id="tgi_outtext" name="tgi_outtext"> -<item><ref id="tgi_outtextxy" name="tgi_outtextxy"> -<item><ref id="tgi_setaspectratio" name="tgi_setaspectratio"> -<item><ref id="tgi_setcolor" name="tgi_setcolor"> -<item><ref id="tgi_setdrawpage" name="tgi_setdrawpage"> -<item><ref id="tgi_setpalette" name="tgi_setpalette"> -<item><ref id="tgi_setpixel" name="tgi_setpixel"> -<item><ref id="tgi_setviewpage" name="tgi_setviewpage"> -<item><ref id="tgi_settextscale" name="tgi_settextscale"> -<item><ref id="tgi_settextstyle" name="tgi_settextstyle"> -<item><ref id="tgi_uninstall" name="tgi_uninstall"> -<item><ref id="tgi_unload" name="tgi_unload"> -</itemize> +<url url="tgi.html" name="Tiny Graphics Interface">. + <sect1><tt/time.h/<label id="time.h"><p> @@ -745,7 +763,7 @@ communication. <itemize> <!-- <item><ref id="chdir" name="chdir"> --> <item><ref id="exec" name="exec"> -<!-- <item><ref id="getcwd" name="getcwd"> --> +<item><ref id="getcwd" name="getcwd"> <item><ref id="getopt" name="getopt"> <!-- <item><ref id="lseek" name="lseek"> --> <!-- <item><ref id="mkdir" name="mkdir"> --> @@ -1377,6 +1395,30 @@ used in presence of a prototype. </quote> +<sect1>atmos_explode<label id="atmos_explode"><p> + +<quote> +<descrip> +<tag/Function/Bomb sound effect. +<tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/ +<tag/Declaration/<tt/void __fastcall__ atmos_explode(void);/ +<tag/Description/<tt/atmos_explode/ plays the BASIC sound. +<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/See also/ +<ref id="atmos_ping" name="atmos_ping">, +<ref id="atmos_shoot" name="atmos_shoot">, +<ref id="atmos_tick" name="atmos_tick">, +<ref id="atmos_tock" name="atmos_tock">, +<ref id="atmos_zap" name="atmos_zap"> +<tag/Example/None. +</descrip> +</quote> + + <sect1>atmos_load<label id="atmos_load"><p> <quote> @@ -1397,6 +1439,30 @@ only in the presence of a prototype. </quote> +<sect1>atmos_ping<label id="atmos_ping"><p> + +<quote> +<descrip> +<tag/Function/Bell or ricochet sound effect. +<tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/ +<tag/Declaration/<tt/void __fastcall__ atmos_ping(void);/ +<tag/Description/<tt/atmos_ping/ plays the BASIC sound. +<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/See also/ +<ref id="atmos_explode" name="atmos_explode">, +<ref id="atmos_shoot" name="atmos_shoot">, +<ref id="atmos_tick" name="atmos_tick">, +<ref id="atmos_tock" name="atmos_tock">, +<ref id="atmos_zap" name="atmos_zap"> +<tag/Example/None. +</descrip> +</quote> + + <sect1>atmos_save<label id="atmos_save"><p> <quote> @@ -1419,6 +1485,102 @@ atmos_save("hires", 0xa000, 0xc000); </quote> +<sect1>atmos_shoot<label id="atmos_shoot"><p> + +<quote> +<descrip> +<tag/Function/Pistol sound effect. +<tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/ +<tag/Declaration/<tt/void __fastcall__ atmos_shoot(void);/ +<tag/Description/<tt/atmos_shoot/ plays the BASIC sound. +<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/See also/ +<ref id="atmos_explode" name="atmos_explode">, +<ref id="atmos_ping" name="atmos_ping">, +<ref id="atmos_tick" name="atmos_tick">, +<ref id="atmos_tock" name="atmos_tock">, +<ref id="atmos_zap" name="atmos_zap"> +<tag/Example/None. +</descrip> +</quote> + + +<sect1>atmos_tick<label id="atmos_tick"><p> + +<quote> +<descrip> +<tag/Function/High-pitch click. +<tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/ +<tag/Declaration/<tt/void __fastcall__ atmos_tick(void);/ +<tag/Description/<tt/atmos_tick/ plays the system sound. +<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/See also/ +<ref id="atmos_explode" name="atmos_explode">, +<ref id="atmos_ping" name="atmos_ping">, +<ref id="atmos_shoot" name="atmos_shoot">, +<ref id="atmos_tock" name="atmos_tock">, +<ref id="atmos_zap" name="atmos_zap"> +<tag/Example/None. +</descrip> +</quote> + + +<sect1>atmos_tock<label id="atmos_tock"><p> + +<quote> +<descrip> +<tag/Function/Low-pitch click. +<tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/ +<tag/Declaration/<tt/void __fastcall__ atmos_tock(void);/ +<tag/Description/<tt/atmos_tock/ plays the system sound. +<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/See also/ +<ref id="atmos_explode" name="atmos_explode">, +<ref id="atmos_ping" name="atmos_ping">, +<ref id="atmos_shoot" name="atmos_shoot">, +<ref id="atmos_tick" name="atmos_tick">, +<ref id="atmos_zap" name="atmos_zap"> +<tag/Example/None. +</descrip> +</quote> + + +<sect1>atmos_zap<label id="atmos_zap"><p> + +<quote> +<descrip> +<tag/Function/Raygun sound effect. +<tag/Header/<tt/<ref id="atmos.h" name="atmos.h">/ +<tag/Declaration/<tt/void __fastcall__ atmos_zap(void);/ +<tag/Description/<tt/atmos_zap/ plays the BASIC sound. +<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/See also/ +<ref id="atmos_explode" name="atmos_explode">, +<ref id="atmos_ping" name="atmos_ping">, +<ref id="atmos_shoot" name="atmos_shoot">, +<ref id="atmos_tick" name="atmos_tick">, +<ref id="atmos_tock" name="atmos_tock"> +<tag/Example/None. +</descrip> +</quote> + + <sect1>atoi<label id="atoi"><p> <quote> @@ -2406,6 +2568,121 @@ be used in presence of a prototype. </quote> +<sect1>cpeekc<label id="cpeekc"><p> + +<quote> +<descrip> +<tag/Function/Get a character from the display memory. +<tag/Header/<tt/<ref id="conio.h" name="conio.h">/ +<tag/Declaration/<tt/char cpeekc (void);/ +<tag/Description/The function gets the character that's at the current location +of the cursor in the display screen RAM. That character is converted, if +needed, into the encoding that can be passed to <tt/cputc()/. +<tag/Notes/<itemize> +<item>Conio peek functions don't have <tt/cpeek...xy()/ versions. That was +done to make it obvious that peeking doesn't move the cursor in any way. Your +program must place the cursor where it wants to peek before it calls any of +those functions. +</itemize> +<tag/Availability/cc65 +<tag/See also/ +<ref id="cpeekcolor" name="cpeekcolor">, +<ref id="cpeekrevers" name="cpeekrevers">, +<ref id="cpeeks" name="cpeeks">, +<ref id="cputc" name="cputc"> +<tag/Example/None. +</descrip> +</quote> + + +<sect1>cpeekcolor<label id="cpeekcolor"><p> + +<quote> +<descrip> +<tag/Function/Get a color from the display memory. +<tag/Header/<tt/<ref id="conio.h" name="conio.h">/ +<tag/Declaration/<tt/unsigned char cpeekcolor (void);/ +<tag/Description/The function gets the color number that's at the current +location of the cursor in the display screen RAM. That number can be passed to +<tt/textcolor()/. +<tag/Notes/<itemize> +<item>Conio peek functions don't have <tt/cpeek...xy()/ versions. That was +done to make it obvious that peeking doesn't move the cursor in any way. Your +program must place the cursor where it wants to peek before it calls any of +those functions. +</itemize> +<tag/Availability/cc65 +<tag/See also/ +<ref id="cpeekc" name="cpeekc">, +<ref id="cpeekrevers" name="cpeekrevers">, +<ref id="cpeeks" name="cpeeks">, +<ref id="cputc" name="cputc">, +<ref id="textcolor" name="textcolor"> +<tag/Example/None. +</descrip> +</quote> + + +<sect1>cpeekrevers<label id="cpeekrevers"><p> + +<quote> +<descrip> +<tag/Function/Get a reverse-character attribute from the display memory. +<tag/Header/<tt/<ref id="conio.h" name="conio.h">/ +<tag/Declaration/<tt/unsigned char cpeekrevers (void);/ +<tag/Description/The function gets the "reverse-mode" attribute of the +character that's at the current location of the cursor in the display screen +RAM. It returns a boolean value (0/1) that can be passed to <tt/revers()/. +<tag/Notes/<itemize> +<item>Conio peek functions don't have <tt/cpeek...xy()/ versions. That was +done to make it obvious that peeking doesn't move the cursor in any way. Your +program must place the cursor where it wants to peek before it calls any of +those functions. +</itemize> +<tag/Availability/cc65 +<tag/See also/ +<ref id="cpeekc" name="cpeekc">, +<ref id="cpeekcolor" name="cpeekcolor">, +<ref id="cpeeks" name="cpeeks">, +<ref id="cputc" name="cputc">, +<ref id="revers" name="revers"> +<tag/Example/None. +</descrip> +</quote> + + +<sect1>cpeeks<label id="cpeeks"><p> + +<quote> +<descrip> +<tag/Function/Get a string from the display memory. +<tag/Header/<tt/<ref id="conio.h" name="conio.h">/ +<tag/Declaration/<tt/void __fastcall__ cpeeks (char* s, unsigned length);/ +<tag/Description/The function gets a fixed-length string ('\0'-terminated) of +characters that start at the current location of the cursor in the display +screen RAM. Those characters are converted, if needed, into the encoding that +can be passed to <tt/cputs()/. The first argument must point to a RAM area +that's large enough to hold "length + 1" bytes. +<tag/Notes/<itemize> +<item>Conio peek functions don't have <tt/cpeek...xy()/ versions. That was +done to make it obvious that peeking doesn't move the cursor in any way. Your +program must place the cursor where it wants to peek before it calls any of +those functions. +<item>The function is available as only a fastcall function; +so, it may be used only in the presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/ +<ref id="cpeekc" name="cpeekc">, +<ref id="cpeekcolor" name="cpeekcolor">, +<ref id="cpeekrevers" name="cpeekrevers">, +<ref id="cputc" name="cputc">, +<ref id="cputs" name="cputs"> +<tag/Example/None. +</descrip> +</quote> + + <sect1>creat<label id="creat"><p> <quote> @@ -2658,6 +2935,126 @@ used in presence of a prototype. </quote> +<sect1>detect_c128<label id="detect_c128"><p> + +<quote> +<descrip> +<tag/Function/Check if a C128 CPU is the current CPU. +<tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/ +<tag/Declaration/<tt/unsigned char detect_c128 (void);/ +<tag/Description/The function returns a 1 if a C128 CPU is the current CPU. +<tag/Notes/<itemize> +<item>The function is specific to the C64 and C128. +</itemize> +<tag/Availability/cc65 (not all platforms) +<tag/See also/ +<ref id="get_c128_speed" name="get_c128_speed">, +<ref id="set_c128_speed" name="set_c128_speed">, +<tag/Example/None. +</descrip> +</quote> + + +<sect1>detect_c64dtv<label id="detect_c64dtv"><p> + +<quote> +<descrip> +<tag/Function/Check for the presence of the C64DTV. +<tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/ +<tag/Declaration/<tt/unsigned char detect_c64dtv (void);/ +<tag/Description/The function returns a 1 if a C64DTV has been detected. +<tag/Notes/<itemize> +<item>The function is specific to the C64. +</itemize> +<tag/Availability/cc65 (not all platforms) +<tag/See also/ +<ref id="get_c64dtv_speed" name="get_c64dtv_speed">, +<ref id="set_c64dtv_speed" name="set_c64dtv_speed">, +<tag/Example/None. +</descrip> +</quote> + + +<sect1>detect_c65<label id="detect_c65"><p> + +<quote> +<descrip> +<tag/Function/Check for the presence of a C65/C64DX in C64 mode. +<tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/ +<tag/Declaration/<tt/unsigned char detect_c65 (void);/ +<tag/Description/The function returns a 1 if a C65/C64DX in C64 mode has been detected. +<tag/Notes/<itemize> +<item>The function is specific to the C64. +</itemize> +<tag/Availability/cc65 (not all platforms) +<tag/See also/ +<ref id="get_c65_speed" name="get_c65_speed">, +<ref id="set_c65_speed" name="set_c65_speed">, +<tag/Example/None. +</descrip> +</quote> + + +<sect1>detect_chameleon<label id="detect_chameleon"><p> + +<quote> +<descrip> +<tag/Function/Check for the presence of the C64 Chameleon cartridge. +<tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/ +<tag/Declaration/<tt/unsigned char detect_chameleon (void);/ +<tag/Description/The function returns a 1 if a C64 Chameleon cartridge has been detected. +<tag/Notes/<itemize> +<item>The function is specific to the C64. +</itemize> +<tag/Availability/cc65 (not all platforms) +<tag/See also/ +<ref id="get_chameleon_speed" name="get_chameleon_speed">, +<ref id="set_chameleon_speed" name="set_chameleon_speed">, +<tag/Example/None. +</descrip> +</quote> + + +<sect1>detect_scpu<label id="detect_scpu"><p> + +<quote> +<descrip> +<tag/Function/Check for the presence of the C64/C128 SuperCPU cartridge. +<tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/ +<tag/Declaration/<tt/unsigned char detect_scpu (void);/ +<tag/Description/The function returns a 1 if a SuperCPU cartridge has been detected. +<tag/Notes/<itemize> +<item>The function is specific to the C128 and C64. +</itemize> +<tag/Availability/cc65 (not all platforms) +<tag/See also/ +<ref id="get_scpu_speed" name="get_scpu_speed">, +<ref id="set_scpu_speed" name="set_scpu_speed">, +<tag/Example/None. +</descrip> +</quote> + + +<sect1>detect_turbomaster<label id="detect_turbomaster"><p> + +<quote> +<descrip> +<tag/Function/Check for the presence of the C64 Turbo Master cartridge. +<tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/ +<tag/Declaration/<tt/unsigned char detect_turbomaster (void);/ +<tag/Description/The function returns a 1 if a C64 Turbo Master cartridge has been detected. +<tag/Notes/<itemize> +<item>The function is specific to the C64. +</itemize> +<tag/Availability/cc65 (not all platforms) +<tag/See also/ +<ref id="get_turbomaster_speed" name="get_turbomaster_speed">, +<ref id="set_turbomaster_speed" name="set_turbomaster_speed">, +<tag/Example/None. +</descrip> +</quote> + + <sect1>div<label id="div"><p> <quote> @@ -2698,9 +3095,9 @@ exits. <tag/Availability/cc65 <tag/Example/<verb> /* Hello World */ -#include <stdio.h> -#include <unistd.h> -#include <cc65.h> +#include <stdio.h> +#include <unistd.h> +#include <cc65.h> int main(void) { printf("Hello World\n"); @@ -3051,20 +3448,21 @@ program, it may not be able to read it. <quote> <descrip> -<tag/Function/Switch the C128 into 2MHz mode. -<tag/Header/<tt/<ref id="c128.h" name="c128.h">/ +<tag/Function/Switch the CPU into fast mode (C128: 2MHz mode, C16/Plus4: double clock mode). +<tag/Header/<tt/<ref id="c128.h" name="c128.h">, +<ref id="c16.h" name="c16.h">, <ref id="plus4.h" name="plus4.h">/ <tag/Declaration/<tt/void fast (void);/ -<tag/Description/The function will switch the clock of the C128 to 2MHz. This -will nearly double the speed compared to slow mode. +<tag/Description/The function will switch the clock of the CPU to fast mode. For the C128 +target it means switching the CPU into 2MHz mode. For the C16/Plus4 target it means +switching the CPU into double clock mode. <tag/Notes/<itemize> -<item>The function is specific to the C128. -<item>2MHz clock will not work in 40 column mode. +<item>The function is specific to the C128, C16 and Plus4. +<item>On the C128 the 2MHz clock will not work in 40 column mode. </itemize> -<tag/Availability/C128 +<tag/Availability/cc65 (not all platforms) <tag/See also/ +<ref id="isfast" name="isfast">, <ref id="slow" name="slow">, -<ref id="toggle_videomode" name="toggle_videomode">, -<ref id="videomode" name="videomode"> <tag/Example/None. </descrip> </quote> @@ -3196,6 +3594,137 @@ header files define constants that can be used to check the return code. </quote> +<sect1>get_c128_speed<label id="get_c128_speed"><p> + +<quote> +<descrip> +<tag/Function/Get the current speed of the C128 CPU. +<tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/ +<tag/Declaration/<tt/unsigned char get_c128_speed (void);/ +<tag/Description/The function returns the current speed of the C128 CPU. +<tag/Notes/<itemize> +<item>The function is specific to the C64 and C128. +<item>The function does not check if the C128 CPU is the current CPU. +<item>See the accelerator.h header for the speed definitions. +</itemize> +<tag/Availability/cc65 (not all platforms) +<tag/See also/ +<ref id="detect_c128" name="detect_c128">, +<ref id="set_c128_speed" name="set_c128_speed">, +<tag/Example/None. +</descrip> +</quote> + + +<sect1>get_c64dtv_speed<label id="get_c64dtv_speed"><p> + +<quote> +<descrip> +<tag/Function/Get the current speed of the C64DTV. +<tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/ +<tag/Declaration/<tt/unsigned char get_c64dtv_speed (void);/ +<tag/Description/The function returns the current speed of the C64DTV. +<tag/Notes/<itemize> +<item>The function is specific to the C64. +<item>The function does not check for the presence of the C64DTV. +<item>See the accelerator.h header for the speed definitions. +</itemize> +<tag/Availability/cc65 (not all platforms) +<tag/See also/ +<ref id="detect_c64dtv" name="detect_c64dtv">, +<ref id="set_c64dtv_speed" name="set_c64dtv_speed">, +<tag/Example/None. +</descrip> +</quote> + + +<sect1>get_c65_speed<label id="get_c65_speed"><p> + +<quote> +<descrip> +<tag/Function/Get the current speed of the C65/C64DX in C64 mode. +<tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/ +<tag/Declaration/<tt/unsigned char get_c65_speed (void);/ +<tag/Description/The function returns the current speed of the C65/C64DX in C64 mode. +<tag/Notes/<itemize> +<item>The function is specific to the C64. +<item>The function does not check for the presence of a C65/C64DX in C64 mode. +<item>See the accelerator.h header for the speed definitions. +</itemize> +<tag/Availability/cc65 (not all platforms) +<tag/See also/ +<ref id="detect_c65" name="detect_c65">, +<ref id="set_c65_speed" name="set_c65_speed">, +<tag/Example/None. +</descrip> +</quote> + + +<sect1>get_chameleon_speed<label id="get_chameleon_speed"><p> + +<quote> +<descrip> +<tag/Function/Get the current speed of the C64 Chameleon cartridge. +<tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/ +<tag/Declaration/<tt/unsigned char get_chameleon_speed (void);/ +<tag/Description/The function returns the current speed of the C64 Chameleon cartridge. +<tag/Notes/<itemize> +<item>The function is specific to the C64. +<item>The function does not check for the presence of the C64 Chameleon cartridge. +<item>See the accelerator.h header for the speed definitions. +</itemize> +<tag/Availability/cc65 (not all platforms) +<tag/See also/ +<ref id="detect_chameleon" name="detect_chameleon">, +<ref id="set_chameleon_speed" name="set_chameleon_speed">, +<tag/Example/None. +</descrip> +</quote> + + +<sect1>get_scpu_speed<label id="get_scpu_speed"><p> + +<quote> +<descrip> +<tag/Function/Get the current speed of the C64/C128 SuperCPU cartridge. +<tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/ +<tag/Declaration/<tt/unsigned char get_scpu_speed (void);/ +<tag/Description/The function returns the current speed of the SuperCPU cartridge. +<tag/Notes/<itemize> +<item>The function is specific to the C128 and C64. +<item>The function does not check for the presence of the cartridge. +<item>See the accelerator.h header for the speed definitions. +</itemize> +<tag/Availability/cc65 (not all platforms) +<tag/See also/ +<ref id="detect_scpu" name="detect_scpu">, +<ref id="set_scpu_speed" name="set_scpu_speed">, +<tag/Example/None. +</descrip> +</quote> + + +<sect1>get_turbomaster_speed<label id="get_turbomaster_speed"><p> + +<quote> +<descrip> +<tag/Function/Get the current speed of the C64 Turbo Master cartridge. +<tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/ +<tag/Declaration/<tt/unsigned char get_turbomaster_speed (void);/ +<tag/Description/The function returns the current speed of the C64 Turbo Master cartridge. +<tag/Notes/<itemize> +<item>The function is specific to the C64. +<item>The function does not check for the presence of the C64 Turbo Master cartridge. +<item>See the accelerator.h header for the speed definitions. +</itemize> +<tag/Availability/cc65 (not all platforms) +<tag/See also/ +<ref id="detect_turbomaster" name="detect_turbomaster">, +<ref id="set_turbomaster_speed" name="set_turbomaster_speed">, +<tag/Example/None. +</descrip> +</quote> + <sect1>getcpu<label id="getcpu"><p> <quote> @@ -3208,6 +3737,11 @@ returns one of the constants<itemize> <item><tt/CPU_6502/ <item><tt/CPU_65C02/ <item><tt/CPU_65816/ +<item><tt/CPU_4510/ +<item><tt/CPU_65SC02/ +<item><tt/CPU_65CE02/ +<item><tt/CPU_HUC6280/ +<item><tt/CPU_2A0x/ </itemize> <tag/Notes/<itemize> <item>Other, more exotic CPU types are not disinguished. @@ -3218,6 +3752,77 @@ returns one of the constants<itemize> </quote> +<sect1>getcurrentdevice<label id="getcurrentdevice"><p> + +<quote> +<descrip> +<tag/Function/Get current device. +<tag/Header/<tt/<ref id="device.h" name="device.h">/ +<tag/Declaration/<tt/unsigned char getcurrentdevice (void);/ +<tag/Description/The function returns the current device. +It allows to access the current device with the <ref id="dio.h" +name="Low-level disk I/O API"> or <ref id="cbm.h" name="cbm_* I/O +functions"> requiring a 'device' parameter. +<tag/Availability/cc65 +<tag/See also/ +<ref id="getdevicedir" name="getdevicedir">, +<ref id="getfirstdevice" name="getfirstdevice">, +<ref id="getnextdevice" name="getnextdevice"> +<tag/Example/<verb> +dio_open (getcurrentdevice ()); +</verb> +</descrip> +</quote> + + +<sect1>getcwd<label id="getcwd"><p> + +<quote> +<descrip> +<tag/Function/Get current working directory. +<tag/Header/<tt/<ref id="unistd.h" name="unistd.h">/ +<tag/Declaration/<tt/char* __fastcall__ getcwd (char* buf, size_t size);/ +<tag/Description/The function will return the current working directory. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +</itemize> +<tag/Availability/POSIX 1003.1 +<tag/Example/None. +</descrip> +</quote> + + +<sect1>getdevicedir<label id="getdevicedir"><p> + +<quote> +<descrip> +<tag/Function/Get device directory. +<tag/Header/<tt/<ref id="device.h" name="device.h">/ +<tag/Declaration/<tt/char* __fastcall__ getdevicedir (unsigned char device, char* buf, size_t size);/ +<tag/Description/The function returns the directory representing <tt/device/. +It allows to access the device on filesystem level by calling chdir() with +the directory returned. +<tag/Notes/<itemize> +<item>Calling getdevicedir() <em/does/ check for a (formatted) disk in a +floppy-disk-type device and returns NULL if that check fails. +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/ +<ref id="getcwd" name="getcwd">, +<ref id="getcurrentdevice" name="getcurrentdevice">, +<ref id="getfirstdevice" name="getfirstdevice">, +<ref id="getnextdevice" name="getnextdevice"> +<tag/Example/<verb> +chdir (getdevicedir (device, buf, sizeof buf)); +</verb> +cf. <tt/samples/enumdevdir.c/ +</descrip> +</quote> + + <sect1>getenv<label id="getenv"><p> <quote> @@ -3241,6 +3846,66 @@ be used in presence of a prototype. </quote> +<sect1>getfirstdevice<label id="getfirstdevice"><p> + +<quote> +<descrip> +<tag/Function/Get first device. +<tag/Header/<tt/<ref id="device.h" name="device.h">/ +<tag/Declaration/<tt/unsigned char getfirstdevice (void);/ +<tag/Description/The function returns the first device. +The constant <tt/INVALID_DEVICE/ indicates no device. +<tag/Notes/<itemize> +<item>Calling getfirstdevice() does <em/not/ turn on the motor of a +drive-type device and does <em/not/ check for a disk in the drive. +</itemize> +<tag/Availability/cc65 +<tag/See also/ +<ref id="getcurrentdevice" name="getcurrentdevice">, +<ref id="getdevicedir" name="getdevicedir">, +<ref id="getnextdevice" name="getnextdevice"> +<tag/Example/<verb> +unsigned char dev = getfirstdevice (); +while (dev != INVALID_DEVICE) { + printf ("%d\n", dev); + dev = getnextdevice (dev); + } +</verb> +</descrip> +</quote> + + +<sect1>getnextdevice<label id="getnextdevice"><p> + +<quote> +<descrip> +<tag/Function/Get next device. +<tag/Header/<tt/<ref id="device.h" name="device.h">/ +<tag/Declaration/<tt/unsigned char __fastcall__ getnextdevice (unsigned char device);/ +<tag/Description/The function returns the next device after <tt/device/. +The constant <tt/INVALID_DEVICE/ indicates no further device. +<tag/Notes/<itemize> +<item>Calling getnextdevice() does <em/not/ turn on the motor of a +drive-type device and does <em/not/ check for a disk in the drive. +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/ +<ref id="getcurrentdevice" name="getcurrentdevice">, +<ref id="getdevicedir" name="getdevicedir">, +<ref id="getfirstdevice" name="getfirstdevice"> +<tag/Example/<verb> +unsigned char dev = getfirstdevice (); +while (dev != INVALID_DEVICE) { + printf ("%d\n", dev); + dev = getnextdevice (dev); + } +</verb> +</descrip> +</quote> + + <sect1>getopt<label id="getopt"><p> <quote> @@ -3578,6 +4243,27 @@ fastcall function, so it may only be used in presence of a prototype. </quote> +<sect1>isfast<label id="isfast"><p> + +<quote> +<descrip> +<tag/Function/Check if the CPU is in fast mode (C128: 2MHz mode, C16/Plus4: double clock mode). +<tag/Header/<tt/<ref id="c128.h" name="c128.h">, +<ref id="c16.h" name="c16.h">, <ref id="plus4.h" name="plus4.h">/ +<tag/Declaration/<tt/unsigned char isfast (void);/ +<tag/Description/The function returns a 1 if the CPU is in fast mode (C128: 2MHz mode, C16/Plus4: double clock mode). +<tag/Notes/<itemize> +<item>The function is specific to the C128, C16 and Plus4. +</itemize> +<tag/Availability/cc65 (not all platforms) +<tag/See also/ +<ref id="fast" name="fast">, +<ref id="slow" name="slow">, +<tag/Example/None. +</descrip> +</quote> + + <sect1>isgraph<label id="isgraph"><p> <quote> @@ -5590,6 +6276,138 @@ clean-up when exitting the program. </quote> +<sect1>set_c128_speed<label id="set_c128_speed"><p> + +<quote> +<descrip> +<tag/Function/Set the current speed of a C128 CPU. +<tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/ +<tag/Declaration/<tt/unsigned char __fastcall__ set_c128_speed (unsigned char speed);/ +<tag/Description/The function returns the speed after trying to set the speed of the C128 CPU. +<tag/Notes/<itemize> +<item>The function is specific to the C64 and C128. +<item>The function does not check if the C128 CPU is the current CPU. +<item>See the accelerator.h header for the speed definitions. +</itemize> +<tag/Availability/cc65 (not all platforms) +<tag/See also/ +<ref id="detect_c128" name="detect_c128">, +<ref id="get_c128_speed" name="get_c128_speed">, +<tag/Example/None. +</descrip> +</quote> + + +<sect1>set_c64dtv_speed<label id="set_c64dtv_speed"><p> + +<quote> +<descrip> +<tag/Function/Set the current speed of the C64DTV. +<tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/ +<tag/Declaration/<tt/unsigned char __fastcall__ set_c64dtv_speed (unsigned char speed);/ +<tag/Description/The function returns the speed after trying to set the speed of the C64DTV. +<tag/Notes/<itemize> +<item>The function is specific to the C64. +<item>The function does not check for the presence of the C64DTV. +<item>See the accelerator.h header for the speed definitions. +</itemize> +<tag/Availability/cc65 (not all platforms) +<tag/See also/ +<ref id="detect_c64dtv" name="detect_c64dtv">, +<ref id="get_c64dtv_speed" name="get_c64dtv_speed">, +<tag/Example/None. +</descrip> +</quote> + + +<sect1>set_c65_speed<label id="set_c65_speed"><p> + +<quote> +<descrip> +<tag/Function/Set the current speed of the C65/C64DX in C64 mode. +<tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/ +<tag/Declaration/<tt/unsigned char __fastcall__ set_c65_speed (unsigned char speed);/ +<tag/Description/The function returns the speed after trying to set the speed of the C65/C64DX in C64 mode. +<tag/Notes/<itemize> +<item>The function is specific to the C64. +<item>The function does not check for the presence of a C65/C64DX in C64 mode. +<item>See the accelerator.h header for the speed definitions. +</itemize> +<tag/Availability/cc65 (not all platforms) +<tag/See also/ +<ref id="detect_c65" name="detect_c65">, +<ref id="get_c65_speed" name="get_c65_speed">, +<tag/Example/None. +</descrip> +</quote> + + +<sect1>set_chameleon_speed<label id="set_chameleon_speed"><p> + +<quote> +<descrip> +<tag/Function/Set the current speed of the C64 Chameleon cartridge. +<tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/ +<tag/Declaration/<tt/unsigned char __fastcall__ set_chameleon_speed (unsigned char speed);/ +<tag/Description/The function returns the speed after trying to set the speed of the C64 Chameleon cartridge. +<tag/Notes/<itemize> +<item>The function is specific to the C64. +<item>The function does not check for the presence of the C64 Chameleon cartridge. +<item>See the accelerator.h header for the speed definitions. +</itemize> +<tag/Availability/cc65 (not all platforms) +<tag/See also/ +<ref id="detect_chameleon" name="detect_chameleon">, +<ref id="get_chameleon_speed" name="get_chameleon_speed">, +<tag/Example/None. +</descrip> +</quote> + + +<sect1>set_scpu_speed<label id="set_scpu_speed"><p> + +<quote> +<descrip> +<tag/Function/Set the current speed of the C64/C128 SuperCPU cartridge. +<tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/ +<tag/Declaration/<tt/unsigned char __fastcall__ set_scpu_speed (unsigned char speed);/ +<tag/Description/The function returns the speed after trying to set the speed of the SuperCPU cartridge. +<tag/Notes/<itemize> +<item>The function is specific to the C128 and C64. +<item>The function does not check for the presence of the cartridge. +<item>See the accelerator.h header for the speed definitions. +</itemize> +<tag/Availability/cc65 (not all platforms) +<tag/See also/ +<ref id="detect_scpu" name="detect_scpu">, +<ref id="get_scpu_speed" name="get_scpu_speed">, +<tag/Example/None. +</descrip> +</quote> + + +<sect1>set_turbomaster_speed<label id="set_turbomaster_speed"><p> + +<quote> +<descrip> +<tag/Function/Set the current speed of the C64 Turbo Master cartridge. +<tag/Header/<tt/<ref id="accelerator.h" name="accelerator.h">/ +<tag/Declaration/<tt/unsigned char __fastcall__ set_turbomaster_speed (unsigned char speed);/ +<tag/Description/The function returns the speed after trying to set the speed of the C64 Turbo Master cartridge. +<tag/Notes/<itemize> +<item>The function is specific to the C64. +<item>The function does not check for the presence of the C64 Turbo Master cartridge. +<item>See the accelerator.h header for the speed definitions. +</itemize> +<tag/Availability/cc65 (not all platforms) +<tag/See also/ +<ref id="detect_turbomaster" name="detect_turbomaster">, +<ref id="get_turbomaster_speed" name="get_turbomaster_speed">, +<tag/Example/None. +</descrip> +</quote> + + <sect1>setjmp<label id="setjmp"><p> <quote> @@ -5686,19 +6504,20 @@ be used in presence of a prototype. <quote> <descrip> -<tag/Function/Switch the C128 into 1MHz mode. -<tag/Header/<tt/<ref id="c128.h" name="c128.h">/ +<tag/Function/Switch the CPU into slow mode (C128: 1MHz mode, C16/Plus4: single clock mode). +<tag/Header/<tt/<ref id="c128.h" name="c128.h">, +<ref id="c16.h" name="c16.h">, <ref id="plus4.h" name="plus4.h">/ <tag/Declaration/<tt/void slow (void);/ -<tag/Description/The function will switch the clock of the C128 to 1MHz. This -will halve the speed compared to fast mode. +<tag/Description/The function will switch the clock of the CPU to slow mode. for the C128 +target it means switching the CPU into 1MHz mode. for the C16/Plus4 target it means +switching the CPU into single clock mode. <tag/Notes/<itemize> -<item>The function is specific to the C128. +<item>The function is specific to the C128, C16 and Plus4. </itemize> -<tag/Availability/C128 +<tag/Availability/cc65 (not all platforms) <tag/See also/ <ref id="fast" name="fast">, -<ref id="toggle_videomode" name="toggle_videomode">, -<ref id="videomode" name="videomode"> +<ref id="isfast" name="isfast">, <tag/Example/None. </descrip> </quote> @@ -6052,6 +6871,34 @@ See <tt/strlower/. </quote> +<sect1>strncasecmp<label id="strncasecmp"><p> + +<quote> +<descrip> +<tag/Function/Compare two strings case insensitive. +<tag/Header/<tt/<ref id="string.h" name="string.h">/ +<tag/Declaration/<tt/int __fastcall__ strncasecmp (const char* s1, const char* s2, size_t count);/ +<tag/Description/The <tt/strncasecmp/ function compares the two strings passed +as parameters without case sensitivity. It returns a value that is less than +zero if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, +and a value greater than zero if <tt/s1/ is greater than <tt/s2/. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +<item>The function is not available in strict ANSI mode. +</itemize> +<tag/Availability/cc65 +<tag/See also/ +<ref id="strcmp" name="strcmp">, +<ref id="strcoll" name="strcoll">, +<ref id="stricmp" name="stricmp">, +<ref id="strncmp" name="strncmp">, +<ref id="strxfrm" name="strxfrm"> +<tag/Example/None. +</descrip> +</quote> + + <sect1>strncat<label id="strncat"><p> <quote> @@ -6145,6 +6992,34 @@ strncpy (hello, "Hello world!\n", sizeof hello - 1)[5] = '\0'; </quote> +<sect1>strnicmp<label id="strnicmp"><p> + +<quote> +<descrip> +<tag/Function/Compare two strings case insensitive. +<tag/Header/<tt/<ref id="string.h" name="string.h">/ +<tag/Declaration/<tt/int __fastcall__ strnicmp (const char* s1, const char* s2, size_t count);/ +<tag/Description/The <tt/strnicmp/ function compares the two strings passed as +parameters without case sensitivity. It returns a value that is less than zero +if <tt/s1/ is less than <tt/s2/, zero if <tt/s1/ is the same as <tt/s2/, and a +value greater than zero if <tt/s1/ is greater than <tt/s2/. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +<item>The function is not available in strict ANSI mode. +</itemize> +<tag/Availability/cc65 +<tag/See also/ +<ref id="strcasecmp" name="strcasecmp">, +<ref id="strcmp" name="strcmp">, +<ref id="strcoll" name="strcoll">, +<ref id="strncmp" name="strncmp">, +<ref id="strxfrm" name="strxfrm"> +<tag/Example/None. +</descrip> +</quote> + + <sect1>strqtok<label id="strqtok"><p> <quote> @@ -6389,979 +7264,6 @@ be used in presence of a prototype. </quote> -<sect1>tgi_arc<label id="tgi_arc"><p> - -<quote> -<descrip> -<tag/Function/Draw an elliptic arc in the current color. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/void __fastcall__ tgi_arc (int x, int y, -unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/ -<tag/Description/The function draws an elliptic arc with center at x/y and -radii rx/ry using the current drawing color. The arc covers the angle -between sa and ea (startangle and endangle), which must be in the range -0..360. -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only -be used in presence of a prototype. -<item>The function behaves unexpectedly or may crash if the angles are out -of range. -</itemize> -<tag/Availability/cc65 -<tag/See also/ -<ref id="tgi_bar" name="tgi_bar">, -<ref id="tgi_circle" name="tgi_circle">, -<ref id="tgi_ellipse" name="tgi_ellipse">, -<ref id="tgi_pieslice" name="tgi_pieslice">, -<ref id="tgi_setcolor" name="tgi_setcolor"> -<tag/Example/<verb> -/* Draw the upper half of an ellipse */ -tgi_setcolor(TGI_COLOR_BLUE); -tgi_arc (50, 50, 40, 20, 0, 180); -</verb> -</descrip> -</quote> - - -<sect1>tgi_bar<label id="tgi_bar"><p> - -<quote> -<descrip> -<tag/Function/The function fills a rectangle on the drawpage with the current -color. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);/ -<tag/Description/The function fills a rectangle on the drawpage with the current -color. -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only -be used in presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/See also/Other tgi function -<tag/Example/<verb> -tgi_setcolor(TGI_COLOR_GREEN); -tgi_bar(10, 10, 100, 60); -</verb> -</descrip> -</quote> - - -<sect1>tgi_circle<label id="tgi_circle"><p> - -<quote> -<descrip> -<tag/Function/The function draws a circle in the current color. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/void __fastcall__ tgi_circle (int x, int y, unsigned char radius);/ -<tag/Description/The function draws a circle in the current color. -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only -be used in presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/See also/ -<ref id="tgi_arc" name="tgi_arc">, -<ref id="tgi_bar" name="tgi_bar">, -<ref id="tgi_ellipse" name="tgi_ellipse">, -<ref id="tgi_pieslice" name="tgi_pieslice">, -<ref id="tgi_setcolor" name="tgi_setcolor"> -<tag/Example/<verb> -tgi_setcolor(TGI_COLOR_BLACK); -tgi_circle(50, 40, 40); -</verb> -</descrip> -</quote> - - -<sect1>tgi_clear<label id="tgi_clear"><p> - -<quote> -<descrip> -<tag/Function/Clear the drawpage -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/void tgi_clear (void);/ -<tag/Description/Clear the drawpage -<tag/Availability/cc65 -<tag/See also/Other tgi functions -<tag/Example/None. -</descrip> -</quote> - - -<sect1>tgi_done<label id="tgi_done"><p> - -<quote> -<descrip> -<tag/Function/End graphics mode, switch back to text mode. -Will NOT uninstall or unload the driver! -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/void tgi_done (void);/ -<tag/Description/End graphics mode, switch back to text mode. -Will NOT uninstall or unload the driver! -<tag/Availability/cc65 -<tag/See also/Other tgi functions -<tag/Example/None. -</descrip> -</quote> - - -<sect1>tgi_ellipse<label id="tgi_ellipse"><p> - -<quote> -<descrip> -<tag/Function/The function draws an ellipse in the current color. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/void __fastcall__ tgi_ellipse (int x, int y, unsigned char rx, unsigned char ry);/ -<tag/Description/The function draws an ellipse at position x/y with radii -rx and ry, using the current drawing color. -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only -be used in presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/See also/ -<ref id="tgi_arc" name="tgi_arc">, -<ref id="tgi_bar" name="tgi_bar">, -<ref id="tgi_circle" name="tgi_circle">, -<ref id="tgi_pieslice" name="tgi_pieslice">, -<ref id="tgi_setcolor" name="tgi_setcolor"> -<tag/Example/<verb> -tgi_setcolor(TGI_COLOR_RED); -tgi_ellipse (50, 40, 40, 20); -</verb> -</descrip> -</quote> - - -<sect1>tgi_free_vectorfont<label id="tgi_free_vectorfont"><p> - -<quote> -<descrip> -<tag/Function/Free a vector font that was previously loaded into memory. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/void __fastcall__ tgi_free_vectorfont (const tgi_vectorfont* font);/ -<tag/Description/Free a vector font that was previously loaded into memory. -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only -be used in presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/See also/ -<ref id="tgi_load_vectorfont" name="tgi_load_vectorfont">, -<ref id="tgi_install_vectorfont" name="tgi_install_vectorfont"> -<tag/Example/None. -</descrip> -</quote> - - -<sect1>tgi_getaspectratio<label id="tgi_getaspectratio"><p> - -<quote> <descrip> <tag/Function/Return the pixel aspect ratio. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/unsigned tgi_getaspectratio (void);/ -<tag/Description/The function returns the pixel aspect ratio for the current -driver and display as an 8.8 fixed point value. It may be used to correct -geometric shapes so they look correct on the display. As an example, a circle -with a radius of 100 pixels may look elliptic on some driver/display -combinations if the aspect ratio is not 1.00. -<tag/Notes/<itemize> -<item>The aspect ratio is encoded in the TGI driver which assumes a "standard" -monitor for the given platform. The aspect ratio may be wrong if another -monitor is used. -<item>No TGI function will use the aspect ratio. It is up to the programmer to -make use of it. -<item>The <ref id="tgi_setaspectratio" name="tgi_setaspectratio"> function can -be used to change the aspect ratio for a loaded driver. The value is not reset -by <ref id="tgi_init" name="tgi_init">, so if a driver is linked statically to -an application, switching into and out of graphics mode will not restore the -original aspect ratio. -</itemize> -<tag/Availability/cc65 -<tag/See also/ -<ref id="tgi_setaspectratio" name="tgi_setaspectratio"> -<tag/Example/None. -</descrip> -</quote> - - -<sect1>tgi_getcolor<label id="tgi_getcolor"><p> - -<quote> -<descrip> -<tag/Function/Return the current drawing color. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/unsigned char tgi_getcolor (void);/ -<tag/Description/The actual color is an index to a palette. During tgi_init -you will get a default palette. The number of colors depend on the platform. -All platforms recognize at least TGI_COLOR_BLACK and TGI_COLOR_WHITE. But some -platforms have many more predefined colors. If you paint using TGI_COLOR_GREEN -and then you change the green of the palette to blue using tgi_setpalette then -after this painting in TGI_COLOR_GREEN will actually be blue. -<tag/Availability/cc65 -<tag/See also/Other tgi functions -<tag/Example/<verb> -color = tgi_getcolor(); -</verb> -</descrip> -</quote> - - -<sect1>tgi_getcolorcount<label id="tgi_getcolorcount"><p> - -<quote> -<descrip> -<tag/Function/Get the number of available colors. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/unsigned char tgi_getcolorcount (void);/ -<tag/Description/Tgi platforms use indexed color palettes. This function -returns the number of entries we can use in the palette. -<tag/Availability/cc65 -<tag/See also/Other tgi functions -<tag/Example/<verb> -if (tgi_getcolorcount() == 2) { - printf("Only monochrome graphics is supported\n"); -} -</verb> -</descrip> -</quote> - - -<sect1>tgi_getdefpalette<label id="tgi_getdefpalette"><p> - -<quote> -<descrip> -<tag/Function/Get the palette installed by default. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/const unsigned char* tgi_getdefpalette (void);/ -<tag/Description/The tgi driver has a default palette that is active at startup. -The named colors TGI_COLOR_BLACK, TGI_COLOR_WHITE, TGI_COLOR_RED... need this -palette to work correctly. -<tag/Availability/cc65 -<tag/See also/Other tgi functions -<tag/Example/None. -</descrip> -</quote> - - -<sect1>tgi_geterror<label id="tgi_geterror"><p> - -<quote> -<descrip> -<tag/Function/Return the error code for the last operation. -This will also clear the error. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/unsigned char tgi_geterror (void);/ -<tag/Description/Return the error code for the last operation. -This will also clear the error. -<tag/Availability/cc65 -<tag/See also/Other tgi functions -<tag/Example/None. -</descrip> -</quote> - - -<sect1>tgi_geterrormsg<label id="tgi_geterrormsg"><p> - -<quote> -<descrip> -<tag/Function/Get an error message describing the error. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/const char* __fastcall__ tgi_geterrormsg (unsigned char code);/ -<tag/Description/Get an error message describing the error. -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only -be used in presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/See also/Other tgi functions -<tag/Example/None. -</descrip> -</quote> - - -<sect1>tgi_getmaxcolor<label id="tgi_getmaxcolor"><p> - -<quote> -<descrip> -<tag/Function/Get the highest index of the palette. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/unsigned char tgi_getmaxcolor (void);/ -<tag/Description/Get the highest index of the palette. -<tag/Availability/cc65 -<tag/See also/Other tgi functions -<tag/Example/None. -</descrip> -</quote> - - -<sect1>tgi_getmaxx<label id="tgi_getmaxx"><p> - -<quote> -<descrip> -<tag/Function/Get the maximum x coordinate that can be used on this screen. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/unsigned tgi_getmaxx (void);/ -<tag/Description/Get the maximum x coordinate that can be used on this screen. -<tag/Availability/cc65 -<tag/See also/Other tgi functions -<tag/Example/None. -</descrip> -</quote> - - -<sect1>tgi_getmaxy<label id="tgi_getmaxy"><p> - -<quote> -<descrip> -<tag/Function/Get the maximum y coordinate that can be used on this screen. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/unsigned tgi_getmaxy (void);/ -<tag/Description/Get the maximum y coordinate that can be used on this screen. -<tag/Availability/cc65 -<tag/See also/Other tgi functions -<tag/Example/None. -</descrip> -</quote> - - -<sect1>tgi_getpagecount<label id="tgi_getpagecount"><p> - -<quote> -<descrip> -<tag/Function/Return the number of screen pages available. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/unsigned tgi_getpagecount (void);/ -<tag/Description/Return the number of screen pages available. -<tag/Availability/cc65 -<tag/See also/ -<ref id="tgi_setdrawpage" name="tgi_setdrawpage">, -<ref id="tgi_setviewpage" name="tgi_setviewpage"> -<tag/Example/None. -</descrip> -</quote> - - -<sect1>tgi_getpalette<label id="tgi_getpalette"><p> - -<quote> -<descrip> -<tag/Function/Get the palette installed. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/const unsigned char* tgi_getpalette (void);/ -<tag/Description/Get the palette installed. -<tag/Availability/cc65 -<tag/See also/Other tgi functions -<tag/Example/None. -</descrip> -</quote> - - -<sect1>tgi_getpixel<label id="tgi_getpixel"><p> - -<quote> -<descrip> -<tag/Function/Get the color of a pixel from the viewpage. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/unsigned char __fastcall__ tgi_getpixel (int x, int y);/ -<tag/Description/Get the color of a pixel from the viewpage. -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only -be used in presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/See also/Other tgi functions. -<tag/Example/None. -</descrip> -</quote> - - -<sect1>tgi_getxres<label id="tgi_getxres"><p> - -<quote> -<descrip> -<tag/Function/Get number of horisontal pixels on the screen. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/unsigned tgi_getxres (void);/ -<tag/Description/Get number of horisontal pixels on the screen. -This is same as tgi_maxx()+1. -<tag/Availability/cc65 -<tag/See also/Other tgi functions. -<tag/Example/None. -</descrip> -</quote> - - -<sect1>tgi_getyres<label id="tgi_getyres"><p> - -<quote> -<descrip> -<tag/Function/Get number of vertical pixels on the screen. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/unsigned tgi_getyres (void);/ -<tag/Description/Get number of vertical pixels on the screen. -This is same as tgi_maxy()+1. -<tag/Availability/cc65 -<tag/See also/Other tgi functions. -<tag/Example/None. -</descrip> -</quote> - - -<sect1>tgi_gotoxy<label id="tgi_gotoxy"><p> - -<quote> -<descrip> -<tag/Function/Set graphics cursor at x, y. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/void __fastcall__ tgi_gotoxy (int x, int y);/ -<tag/Description/Set graphics cursor at x, y. -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only -be used in presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/See also/Other tgi functions. -<tag/Example/None. -</descrip> -</quote> - - -<sect1>tgi_init<label id="tgi_init"><p> - -<quote> -<descrip> -<tag/Function/Initialize the already loaded graphics driver. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/void tgi_init (void);/ -<tag/Description/The tgi_init function will set the default palette to the -hardware. -<tag/Notes/<itemize> -<item><tt/tgi_init/ will not clear the screen. This allows switching between -text and graphics mode on platforms that have separate memory areas for the -screens. If you want the screen cleared, call <tt/<ref id="tgi_clear" -name="tgi_clear">/ after <tt/tgi_init/. -</itemize> -<tag/Availability/cc65 -<tag/See also/Other tgi functions. -<tag/Example/<verb> -tgi_install(tgi_static_stddrv); //Include the driver statically instead of loading it. -tgi_init(); //Set up the default palette and clear the screen. -</verb> -</descrip> -</quote> - - -<sect1>tgi_install<label id="tgi_install"><p> - -<quote> -<descrip> -<tag/Function/Install an already loaded driver and return an error code. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/unsigned char __fastcall__ tgi_install (void* driver);/ -<tag/Description/The function installs a driver that was already loaded into -memory (or linked statically to the program). It returns an error code -(<tt/TGI_ERR_OK/ in case of success). -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only be -used in presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/See also/ -<ref id="tgi_load_driver" name="tgi_load_driver">, -<ref id="tgi_uninstall" name="tgi_uninstall">, -<ref id="tgi_unload" name="tgi_unload"> -<tag/Example/<verb> -tgi_install(tgi_static_stddrv); //Include the driver statically instead of loading it. -tgi_init(); //Set up the default palette and clear the screen. -</verb> -</descrip> -</quote> - - -<sect1>tgi_install_vectorfont<label id="tgi_install_vectorfont"><p> - -<quote> -<descrip> -<tag/Function/Install an already loaded driver and return an error code. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/void __fastcall__ tgi_install_vectorfont (const tgi_vectorfont* font);/ -<tag/Description/ -Install a vector font for use. More than one vector font can be loaded, -but only one can be active. This function is used to tell which one. Call -with a NULL pointer to uninstall the currently installed font. -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only be -used in presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/See also/ -<ref id="tgi_load_vectorfont" name="tgi_load_vectorfont">, -<ref id="tgi_free_vectorfont" name="tgi_free_vectorfont"> -<tag/Example/None. -</descrip> -</quote> - - -<sect1>tgi_ioctl<label id="tgi_ioctl"><p> - -<quote> -<descrip> -<tag/Function/Platform dependent code extensions. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/unsigned __fastcall__ tgi_ioctl (unsigned char code, void* data);/ -<tag/Description/Some platforms have extra display hardware that is not -supported by standard tgi functions. You can extend the driver to support -this extra hardware using tgi_ioctl functions. -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only -be used in presence of a prototype. -<item>These functions are not easily portable to other cc65 platforms. -</itemize> -<tag/Availability/cc65 -<tag/See also/Other tgi functions. -<tag/Example/<verb> -#define tgi_sprite(spr) tgi_ioctl(0, (void*)(spr)) -#define tgi_flip() tgi_ioctl(1, (void*)0) -#define tgi_setbgcolor(bgcol) tgi_ioctl(2, (void*)(bgcol)) -#define tgi_setframerate(rate) tgi_ioctl(3, (void*)(rate)) -#define tgi_busy() tgi_ioctl(4, (void*)0) -#define tgi_updatedisplay() tgi_ioctl(4, (void*)1) -if (!tgi_busy()) { - tgi_sprite(&background); - tgi_setcolor(TGI_COLOR_BLUE); - tgi_outttextxy(20,40,"Hello World"); - tgi_updatedisplay(); -} -</verb> -</descrip> -</quote> - - -<sect1>tgi_line<label id="tgi_line"><p> - -<quote> -<descrip> -<tag/Function/Draw a line in the current drawing color. -The graphics cursor will be set to x2/y2 by this call. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/void __fastcall__ tgi_line (int x1, int y1, int x2, int y2);/ -<tag/Description/Draw a line in the current drawing color. -The graphics cursor will be set to x2/y2 by this call. -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only -be used in presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/See also/Other tgi functions. -<tag/Example/None. -</descrip> -</quote> - - -<sect1>tgi_lineto<label id="tgi_lineto"><p> - -<quote> -<descrip> -<tag/Function/Draw a line in the current drawing color from the graphics -cursor to the new end point. The graphics cursor will be updated to x2/y2. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/void __fastcall__ tgi_lineto (int x2, int y2);/ -<tag/Description/Draw a line in the current drawing color from the graphics -cursor to the new end point. The graphics cursor will be updated to x2/y2. -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only -be used in presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/See also/Other tgi functions. -<tag/Example/None. -</descrip> -</quote> - - -<sect1>tgi_load_driver<label id="tgi_load_driver"><p> - -<quote> -<descrip> -<tag/Function/Load and install the given driver. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/void __fastcall__ tgi_load_driver (const char *name);/ -<tag/Description/Load and install the driver by name. -Will just load the driver and check if loading was successful. -Will not switch to graphics mode. -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only -be used in presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/See also/Other tgi functions. -<tag/Example/None. -</descrip> -</quote> - - -<sect1>tgi_load_vectorfont<label id="tgi_load_vectorfont"><p> - -<quote> -<descrip> -<tag/Function/Load the given vector font. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/const tgi_vectorfont* __fastcall__ tgi_load_vectorfont (const char* name);/ -<tag/Description/ -Load a vector font into memory and return it. In case of errors, NULL is -returned and an error is set, which can be retrieved using tgi_geterror. -To use the font, it has to be installed using tgi_install_vectorfont. -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only -be used in presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/See also/ -<ref id="tgi_install_vectorfont" name="tgi_install_vectorfont">, -<ref id="tgi_free_vectorfont" name="tgi_free_vectorfont"> -<tag/Example/None. -</descrip> -</quote> - - -<sect1>tgi_outtext<label id="tgi_outtext"><p> - -<quote> -<descrip> -<tag/Function/Output text at the current graphics cursor position. -The graphics cursor is moved to the end of the text. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/void __fastcall__ tgi_outtext (const char* s);/ -<tag/Description/Output text at the current graphics cursor position. -The graphics cursor is moved to the end of the text. -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only -be used in presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/See also/Other tgi functions. -<tag/Example/None. -</descrip> -</quote> - - -<sect1>tgi_outtextxy<label id="tgi_outtextxy"><p> - -<quote> -<descrip> -<tag/Function/Output text at the given cursor position. -The graphics cursor is moved to the end of the text. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/void __fastcall__ tgi_outtextxy (int x, int y, const char* s);/ -<tag/Description/Output text at the given cursor position. -The graphics cursor is moved to the end of the text. -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only -be used in presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/See also/Other tgi functions. -<tag/Example/None. -</descrip> -</quote> - - -<sect1>tgi_pieslice<label id="tgi_pieslice"><p> - -<quote> -<descrip> -<tag/Function/Draw an elliptic pie slice in the current color. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/void __fastcall__ tgi_pie slice (int x, int y, -unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/ -<tag/Description/The function draws an elliptic pie slice with center at x/y -and radii rx/ry using the current drawing color. The pie slice covers the angle -between sa and ea (startangle and endangle), which must be in the range -0..360. -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only -be used in presence of a prototype. -<item>The function behaves unexpectedly or may crash if the angles are out -of range. -</itemize> -<tag/Availability/cc65 -<tag/See also/ -<ref id="tgi_bar" name="tgi_arc">, -<ref id="tgi_bar" name="tgi_bar">, -<ref id="tgi_circle" name="tgi_circle">, -<ref id="tgi_ellipse" name="tgi_ellipse">, -<ref id="tgi_setcolor" name="tgi_setcolor"> -<tag/Example/<verb> -/* Draw the closed upper half of an ellipse */ -tgi_setcolor(TGI_COLOR_BLUE); -tgi_pieslice (50, 50, 40, 20, 0, 180); -</verb> -</descrip> -</quote> - - -<sect1>tgi_setaspectratio<label id="tgi_setaspectratio"><p> - -<quote> <descrip> <tag/Function/Set the pixel aspect ratio. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/void __fastcall__ tgi_setaspectratio (unsigned ratio);/ -<tag/Description/The function sets the pixel aspect ratio for the current -driver and display. The argument is an 8.8 fixed point value. The aspect ratio -may be used to correct geometric shapes so they look correct on a given -display. As an example, a circle with a radius of 100 pixels may look elliptic -on some driver/display combinations if the aspect ratio is not 1.00. -<tag/Notes/<itemize> -<item>The aspect ratio is encoded in the TGI driver which assumes a "standard" -monitor for the given platform. The aspect ratio may be wrong if another -monitor is used. -<item>No TGI function will use the aspect ratio. It is up to the programmer to -make use of it. -<item>The <tt/tgi_setaspectratio/ function can be used to change the aspect -ratio for a loaded driver. The value is not reset by <ref id="tgi_init" -name="tgi_init">, so if a driver is linked statically to an application, -switching into and out of graphics mode will not restore the original aspect -ratio. -<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/See also/ -<ref id="tgi_getaspectratio" name="tgi_getaspectratio"> -<tag/Example/None. -</descrip> -</quote> - - -<sect1>tgi_setcolor<label id="tgi_setcolor"><p> - -<quote> -<descrip> -<tag/Function/Set color to be used in future draw operations. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/void __fastcall__ tgi_setcolor (unsigned char color);/ -<tag/Description/Set color to be used in future draw operations. -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only -be used in presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/See also/Other tgi functions. -<tag/Example/<verb> -tgi_setcolor(TGI_COLOR_BLACK); -tgi_bar(0,0,30,30); -tgi_setcolor(TGI_COLOR_WHITE); -tgi_bar(10,10,20,20); -</verb> -</descrip> -</quote> - -<sect1>tgi_setdrawpage<label id="tgi_setdrawpage"><p> - -<quote> -<descrip> -<tag/Function/Set the page for drawing. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/void __fastcall__ tgi_setdrawpage (unsigned char page);/ -<tag/Description/If the drawpage and the viewpage are the same then all drawing -is seen immediately as it is drawn. For double buffered games you can set the -drawpage to a different page than the viewpage. This lets you draw the next -screen in the background and when the screen is ready you display it. -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only -be used in presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/See also/Other tgi functions. -<tag/Example/<verb> -tgi_setdrawpage(1); -tgi_outtextxy(10, 10, "Hello World"); -tgi_setviewpage(1); // Show page 1 -tgi_setdrawpage(0); -tgi_outtextxy(10, 10, "Creating next frame"); -... -tgi_setviewpage(0); // Show page 0 -</verb> -</descrip> -</quote> - -<sect1>tgi_setpalette<label id="tgi_setpalette"><p> - -<quote> -<descrip> -<tag/Function/Set the palette (not available with all drivers/hardware). -Palette is a pointer to as many entries as there are colors. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/void __fastcall__ tgi_setpalette (const unsigned char* palette);/ -<tag/Description/Set the palette (not available with all drivers/hardware). -Palette is a pointer to as many entries as there are colors. -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only -be used in presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/See also/Other tgi functions. -<tag/Example/None. -</descrip> -</quote> - -<sect1>tgi_setpixel<label id="tgi_setpixel"><p> - -<quote> -<descrip> -<tag/Function/Plot a pixel on the drawpage with the current color. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/void __fastcall__ tgi_setpixel (int x, int y);/ -<tag/Description/Plot a pixel on the drawpage with the current color. -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only -be used in presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/See also/Other tgi functions. -<tag/Example/None. -</descrip> -</quote> - -<sect1>tgi_setviewpage<label id="tgi_setviewpage"><p> - -<quote> -<descrip> -<tag/Function/Set page to be visible on screen. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/void __fastcall__ tgi_setviewpage (unsigned char page);/ -<tag/Description/If the drawpage and the viewpage are the same then all drawing -is seen immediately as it is drawn. For double buffered games you can set the -drawpage to a different page than the viewpage. This lets you draw the next -screen in the background and when the screen is ready you display it. -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only -be used in presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/See also/Other tgi functions. -<tag/Example/<verb> -tgi_setdrawpage(1); -tgi_outtextxy(10, 10, "Hello World"); -tgi_setviewpage(1); // Show page 1 -tgi_setdrawpage(0); -tgi_outtextxy(10, 10, "Creating next frame"); -... -tgi_setviewpage(0); // Show page 0 -</verb> -</descrip> -</quote> - -<sect1>tgi_gettextheight<label id="tgi_gettextheight"><p> - -<quote> -<descrip> -<tag/Function/Calculate the height of the text in pixels according to -the current text style. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextheight (const char* s);/ -<tag/Description/Calculate the height of the text in pixels according to -the current text style. -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only -be used in presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/See also/Other tgi functions. -<tag/Example/None. -</descrip> -</quote> - -<sect1>tgi_settextscale<label id="tgi_settextscale"><p> - -<quote> -<descrip> -<tag/Function/Set the scaling for text output. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/void __fastcall__ tgi_settextscale (unsigned width, unsigned height);/ -<tag/Description/ -Set the scaling for text output. The scaling factors for width and height -are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc. -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only -be used in presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/See also/ -<ref id="tgi_settextstyle" name="tgi_settextstyle"> -<tag/Example/None. -</descrip> -</quote> - -<sect1>tgi_settextstyle<label id="tgi_settextstyle"><p> - -<quote> -<descrip> -<tag/Function/Set the style for text output. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/void __fastcall__ tgi_settextstyle (unsigned char magx, unsigned char magy, unsigned char dir, unsigned char font);/ -<tag/Description/Set the style for text output. -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only -be used in presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/See also/ -<ref id="tgi_settextscale" name="tgi_settextscale"> -<tag/Example/None. -</descrip> -</quote> - -<sect1>tgi_gettextwidth<label id="tgi_gettextwidth"><p> - -<quote> -<descrip> -<tag/Function/Calculate the width of the text in pixels according to the current text style. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextwidth (const char* s);/ -<tag/Description/Calculate the width of the text in pixels according to the current text style. -<tag/Notes/<itemize> -<item>The function is only available as fastcall function, so it may only -be used in presence of a prototype. -</itemize> -<tag/Availability/cc65 -<tag/See also/Other tgi functions. -<tag/Example/None. -</descrip> -</quote> - -<sect1>tgi_uninstall<label id="tgi_uninstall"><p> - -<quote> -<descrip> -<tag/Function/Uninstall the currently loaded driver but do not unload it. -Will call tgi_done if necessary. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/void tgi_uninstall (void);/ -<tag/Description/Uninstall the currently loaded driver but do not unload it. -Will call tgi_done if necessary. -<tag/Availability/cc65 -<tag/See also/Other tgi functions. -<tag/Example/None. -</descrip> -</quote> - -<sect1>tgi_unload<label id="tgi_unload"><p> - -<quote> -<descrip> -<tag/Function/Uninstall, then unload the currently loaded driver. -Will call tgi_done if necessary. -<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ -<tag/Declaration/<tt/void tgi_unload (void);/ -<tag/Description/Uninstall, then unload the currently loaded driver. -Will call tgi_done if necessary. -<tag/Availability/cc65 -<tag/See also/Other tgi functions. -<tag/Example/None. -</descrip> -</quote> - <sect1>time<label id="time"><p> <quote> @@ -7405,6 +7307,7 @@ name="videomode"> instead! <tag/Availability/C128 <tag/See also/ <ref id="fast" name="fast">, +<ref id="isfast" name="isfast">, <ref id="slow" name="slow">, <ref id="videomode" name="videomode"> <tag/Example/None. @@ -7605,6 +7508,7 @@ used in presence of a prototype. <tag/Availability/C128 and enhanced Apple //e <tag/See also/ <ref id="fast" name="fast">, +<ref id="isfast" name="isfast">, <ref id="slow" name="slow">, <ref id="toggle_videomode" name="toggle_videomode"> <tag/Example/None. @@ -7612,6 +7516,24 @@ used in presence of a prototype. </quote> +<sect1>waitvsync<label id="waitvsync"><p> + +<quote> +<descrip> +<tag/Function/Wait until the start of the next frame. +<tag/Header/ +<tt/<ref id="cbm.h" name="cbm.h">/, +<tt/<ref id="gamate.h" name="gamate.h">/, +<tt/<ref id="nes.h" name="nes.h">/, +<tt/<ref id="pce.h" name="pce.h">/ +<tag/Declaration/<tt/void waitvsync (void);/ +<tag/Description/Wait for vertical sync to reduce flickering. +<tag/Availability/Platforms above +<tag/Example/None. +</descrip> +</quote> + + <sect1>wherex<label id="wherex"><p> <quote> diff --git a/doc/gamate.sgml b/doc/gamate.sgml index 14b1a27e9..0948c20c4 100644 --- a/doc/gamate.sgml +++ b/doc/gamate.sgml @@ -44,6 +44,13 @@ by an external program. Such an utility is provided in util/gamate/gamate-fixcar Programs containing Gamate specific code may use the <tt/gamate.h/ header file. +<sect1>Gamate specific functions<p> + +<itemize> +<item>waitvsync</item> +</itemize> + + <sect1>Hardware access<p> The following pseudo variables declared in the <tt/gamate.inc/ include file do diff --git a/doc/index.sgml b/doc/index.sgml index 99b4f10b5..a7aa06037 100644 --- a/doc/index.sgml +++ b/doc/index.sgml @@ -85,6 +85,9 @@ <tag><htmlurl url="dio.html" name="dio.html"></tag> Low-level disk I/O API. + <tag><htmlurl url="tgi.html" name="tgi.html"></tag> + Tiny Graphics Interface. + <tag><htmlurl url="geos.html" name="geos.html"></tag> The GEOSLib manual. diff --git a/doc/intro.sgml b/doc/intro.sgml index bb8965c60..47516e671 100644 --- a/doc/intro.sgml +++ b/doc/intro.sgml @@ -246,13 +246,13 @@ varies in its start and exit conditions. <sect2>AppleWin<p> Available at <url -url="http://applewin.berlios.de/">: +url="https://github.com/AppleWin/AppleWin">: Emulates Apple ][/enhanced Apple //e computers, with sound, video, joysticks, serial port, and disk images. Includes monitor. Only for Windows. The package comes with a DOS 3.3 disk (called "master.dsk") image; -however, you will need <bf/AppleCommander 1.3.5/ or later (available at <url -url="http://applecommander.sourceforge.net/">). +however, you will need <bf/AppleCommander 1.4.0/ or later (available at <url +url="https://applecommander.github.io/">). Compile the tutorial with @@ -270,14 +270,13 @@ the <tt/master.dsk/ which comes with <bf/AppleWin/, and rename it to <tt/cc65.dsk/, then use <bf/AppleCommander/: <tscreen><verb> -java -jar ac.jar -cc65 cc65.dsk test B < hello +java -jar ac.jar -as cc65.dsk test < hello </verb></tscreen> Note that a convention in the Apple world is that "hello" is the file which is run automatically upon booting a DOS disk, sort of like the "autoexec.bat" of -the MSDOS/Windows world. We've avoided that in the example, however. Also, -the <tt/B/ parameter must be in caps., and "test" is the name of the program as -it will appear on the Apple disk. +the MSDOS/Windows world. We've avoided that in the example, however by using +"test" as the name of the program as it will appear on the Apple disk. Start the emulator, click on the <bf/Disk 1/ icon, and point to <bf/cc65.dsk/; then, click the big Apple logo, to boot the system. Then, type this on the diff --git a/doc/library.sgml b/doc/library.sgml index 9b923c308..c36605844 100644 --- a/doc/library.sgml +++ b/doc/library.sgml @@ -4,7 +4,7 @@ <title>cc65 Library Overview <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz"> -<date>2014-04-12 +<date>2018-02-28 <abstract> An overview over the runtime and C libraries that come with the cc65 compiler, @@ -43,7 +43,7 @@ Functions that are <em/not/ available: <itemize> <item><tt>tmpfile/tmpnam</tt> <p> - <item><tt>system</tt> + <item><tt>system</tt> (cc65 alternative <tt>exec</tt>) <p> <item>All functions that handle floating point numbers in some manner. <p> @@ -172,10 +172,15 @@ portable. conio implementations exist for the following targets: <item>plus4 (or expanded c16/c116) <item>cbm510 (40 column video) <item>cbm610 (all CBM series-II computers with 80 column video) + <item>creativision + <item>gamate <item>geos-apple <item>geos-cbm <item>nes + <item>osic1p + <item>pce <item>pet (all CBM PET systems except the 2001) + <item>telestrat <item>vic20 </itemize> @@ -204,6 +209,7 @@ the following targets: <item>atarixl <item>c64 <item>c128 + <item>cbm510 </itemize> The available functions are declared in <tt/mouse.h/. @@ -235,6 +241,3 @@ freely, subject to the following restrictions: </enum> </article> - - - diff --git a/doc/pce.sgml b/doc/pce.sgml index 927df8f5c..bc7dcf5c8 100644 --- a/doc/pce.sgml +++ b/doc/pce.sgml @@ -3,9 +3,9 @@ <article> <title>PC-Engine (TurboGrafx) System specific information for cc65 -<author> -<url url="mailto:groepaz@gmx.net" name="Groepaz/Hitmen"> -<date>2016-09-29 +<author><url url="mailto:groepaz@gmx.net" name="Groepaz/Hitmen">,<newline> +<url url="mailto:greg.king5@verizon.net" name="Greg King"> +<date>2018-02-12 <abstract> An overview over the PCE runtime system as it is implemented for the @@ -30,11 +30,36 @@ more than one platform. Please see the function reference for more information. + <sect>Binary format<p> -The standard binary output format generated by the linker for the PCE target -is a cartridge image with no header. It is of course possible to change this -behaviour by using a modified startup file and linker config. +The binary output file generated by the linker, for the PCE target, is an +image, with no header, that has 8K bytes in the wrong place. That file must be +post-processed; the 8K at the end must be moved to the front of the image. + +On POSIX systems, the <tt/dd/ command and the shell give a convenient way to do +it. Here is an example of their use: +<tscreen><verb> +dd if=conio.bin bs=8K skip=3 > conio.pce +dd if=conio.bin bs=8K count=3 >> conio.pce +</verb></tscreen> +The first command grabs the last 8K of a 32K file, and writes it as the first +part of a new file. The second command reads all but the last part of the old +file, and appends it to the new file. +<tscreen><verb> ++--------+--------+--------+--------+ +| Bank 1 | Bank 2 | Bank 3 | Bank 0 | <-- "conio.bin" ++--------+--------+--------+--------+ + ++--------+--------+--------+--------+ +| Bank 0 | Bank 1 | Bank 2 | Bank 3 | <-- "conio.pce" ++--------+--------+--------+--------+ +</verb></tscreen> +<em/Note/: That <tt/.pce/ file shows the format of the ROM cartridge that is +plugged into a PC-Engine. But, that <tt/.bin/ file shows what programs +actually see when they execute the code in that cartridge. + + <sect>Memory layout<p> @@ -52,19 +77,23 @@ Special locations: <tag/Stack/ The C runtime stack is located in system RAM at $3FFF and growing downwards. - <tag/BSS and Data/ - - The BSS (uninitialized variables) and Data (initialized variables) sections are - placed one after the other into system RAM at $2000. + <tag/Data and BSS/ + The Data (initialized variables) and BSS (uninitialized variables) sections are + placed one after the other into system RAM at $2200. <tag/Heap/ - The C heap is located after the end of the Data section and grows towards the C + The C heap is located after the end of the BSS section; and, grows towards the C runtime stack. <tag/Code/ - The startup code is located at $E000 in the System/Hardware bank. Further - code can be placed in other ROM banks, this must be done manually however. + In an 8K ROM cartridge, code and read-only data are located between + $E000 and $FFF5 in the System bank. + In a 16K cartridge, code and read-only data are located between $C000 + and $FFF5. + + In a 32K cartridge, code and read-only data are located between $8000 + and $FFF5. </descrip><p> @@ -171,7 +200,8 @@ following functions (and a few others): <sect>Other hints<p> <itemize> -<item>a good emulator to use for PC-Engine is "mednafen" (<url url="http://mednafen.fobby.net/">) +<item><url url="https://mednafen.github.io/" name= "Mednafen"> is a good +emulator to use for the PC-Engine. </itemize> some useful resources on PCE coding: @@ -210,6 +240,3 @@ freely, subject to the following restrictions: </enum> </article> - - - diff --git a/doc/plus4.sgml b/doc/plus4.sgml index 36d53e753..c1b6165f6 100644 --- a/doc/plus4.sgml +++ b/doc/plus4.sgml @@ -124,6 +124,19 @@ declaration and usage. </itemize> +<sect1>CBM specific CPU functions<p> + +Some CPU related functions are available for some of the Commodore +machines. See the <url url="funcref.html" name="function reference"> for +declaration and usage. + +<itemize> +<item>fast +<item>slow +<item>isfast +</itemize> + + <sect1>Hardware access<p> The following pseudo variables declared in the <tt/plus4.h/ header file do diff --git a/doc/supervision.sgml b/doc/supervision.sgml index cf2af7967..153746025 100644 --- a/doc/supervision.sgml +++ b/doc/supervision.sgml @@ -4,7 +4,7 @@ <title>Watara Supervision specific information for cc65 <author><url url="mailto:polluks@sdf.lonestar.org" name="Stefan A. Haubenthal"> -<date>2014-04-12 +<date>2017-11-21 <abstract> An overview over the Supervision runtime system as it is implemented for the @@ -63,14 +63,6 @@ Special locations: Programs containing Supervision specific code may use the <tt/supervision.h/ header file. -<sect1>Supervision specific functions<p> - -<itemize> -<item>waitvsync</item> -</itemize> - - - <sect1>Hardware access<p> The following pseudo variables declared in the <tt/supervision.inc/ include file do @@ -102,11 +94,12 @@ No extended memory drivers are currently available for the Supervision. <sect1>Joystick drivers<p> -No joystick drivers are currently available for the Supervision. -<!--A joystick driver for the standard buttons is available, but must be -statically linked, because no file I/O is available. See the documentation for -the <url url="co65.html" name="co65 utility"> for information on how to do -that.--> +<descrip> + + <tag><tt/supervision-stdjoy.joy (supervision_stdjoy_joy)/</tag> + A joystick driver for the standard two buttons joypad is available. + +</descrip><p> <sect1>Mouse drivers<p> diff --git a/doc/telestrat.sgml b/doc/telestrat.sgml index 243097a84..76b3cdd30 100644 --- a/doc/telestrat.sgml +++ b/doc/telestrat.sgml @@ -9,9 +9,7 @@ <date>2017-01-22 <abstract> -An overview over the Telestrat (<url name="Telemon 3.0" -url="http://orix.oric.org">) runtime system as it is implemented for the -cc65 C compiler. +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 --> @@ -117,6 +115,20 @@ structures; accessing the struct fields will access the chip registers. <sect>Loadable drivers<p> +<sect1>TGI<p> + +TGI drivers is available on Oric Telestrat with some functions : + +<itemize> +<item>tgi_done +<item>tgi_install +<item>tgi_init +<item>tgi_clear +<item>tgi_line +<item>tgi_setpixel +</itemize> + + <sect1>Extended memory drivers<p> No extended memory drivers are currently available for the Telestrat. @@ -143,7 +155,7 @@ Telestrat manages also mouse, but it had been no handled yet in this version. <descrip> -Telestrat has a RS232 port, but it's not used +Telestrat has a RS232 port, but it's not usable in cc65. </descrip> diff --git a/doc/tgi.sgml b/doc/tgi.sgml new file mode 100644 index 000000000..cf90fd198 --- /dev/null +++ b/doc/tgi.sgml @@ -0,0 +1,1003 @@ +<!doctype linuxdoc system> + +<article> +<title>Tiny Graphics Interface +<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline> +<url url="mailto:polluks@sdf.lonestar.org" name="Stefan A. Haubenthal">,<newline> +<url url="mailto:greg.king5@verizon.net" name="Greg King"> +<date>2017-11-30 + +<abstract> +The cc65 library provides functions for platform independent graphics. +Include the tgi.h header file to get the necessary definitions. +</abstract> + +<!-- Begin the document --> + +<sect>tgi.h<label id="tgi.h"> + +<sect1>tgi_arc<label id="tgi_arc"><p> + +<quote> +<descrip> +<tag/Function/Draw an elliptic arc in the current color. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/void __fastcall__ tgi_arc (int x, int y, +unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/ +<tag/Description/The function draws an elliptic arc with center at x/y and +radii rx/ry using the current drawing color. The arc covers the angle +between sa and ea (startangle and endangle), which must be in the range +0..360. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +<item>The function behaves unexpectedly or may crash if the angles are out +of range. +</itemize> +<tag/Availability/cc65 +<tag/See also/ +<ref id="tgi_bar" name="tgi_bar">, +<ref id="tgi_circle" name="tgi_circle">, +<ref id="tgi_ellipse" name="tgi_ellipse">, +<ref id="tgi_pieslice" name="tgi_pieslice">, +<ref id="tgi_setcolor" name="tgi_setcolor"> +<tag/Example/<verb> +/* Draw the upper half of an ellipse */ +tgi_setcolor(TGI_COLOR_BLUE); +tgi_arc (50, 50, 40, 20, 0, 180); +</verb> +</descrip> +</quote> + + +<sect1>tgi_bar<label id="tgi_bar"><p> + +<quote> +<descrip> +<tag/Function/The function fills a rectangle on the drawpage with the current +color. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);/ +<tag/Description/The function fills a rectangle on the drawpage with the current +color. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/Other tgi function +<tag/Example/<verb> +tgi_setcolor(TGI_COLOR_GREEN); +tgi_bar(10, 10, 100, 60); +</verb> +</descrip> +</quote> + + +<sect1>tgi_circle<label id="tgi_circle"><p> + +<quote> +<descrip> +<tag/Function/The function draws a circle in the current color. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/void __fastcall__ tgi_circle (int x, int y, unsigned char radius);/ +<tag/Description/The function draws a circle in the current color. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/ +<ref id="tgi_arc" name="tgi_arc">, +<ref id="tgi_bar" name="tgi_bar">, +<ref id="tgi_ellipse" name="tgi_ellipse">, +<ref id="tgi_pieslice" name="tgi_pieslice">, +<ref id="tgi_setcolor" name="tgi_setcolor"> +<tag/Example/<verb> +tgi_setcolor(TGI_COLOR_BLACK); +tgi_circle(50, 40, 40); +</verb> +</descrip> +</quote> + + +<sect1>tgi_clear<label id="tgi_clear"><p> + +<quote> +<descrip> +<tag/Function/Clear the drawpage +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/void tgi_clear (void);/ +<tag/Description/Clear the drawpage +<tag/Availability/cc65 +<tag/See also/Other tgi functions +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_done<label id="tgi_done"><p> + +<quote> +<descrip> +<tag/Function/End graphics mode, switch back to text mode. +Will NOT uninstall or unload the driver! +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/void tgi_done (void);/ +<tag/Description/End graphics mode, switch back to text mode. +Will NOT uninstall or unload the driver! +<tag/Availability/cc65 +<tag/See also/Other tgi functions +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_ellipse<label id="tgi_ellipse"><p> + +<quote> +<descrip> +<tag/Function/The function draws an ellipse in the current color. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/void __fastcall__ tgi_ellipse (int x, int y, unsigned char rx, unsigned char ry);/ +<tag/Description/The function draws an ellipse at position x/y with radii +rx and ry, using the current drawing color. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/ +<ref id="tgi_arc" name="tgi_arc">, +<ref id="tgi_bar" name="tgi_bar">, +<ref id="tgi_circle" name="tgi_circle">, +<ref id="tgi_pieslice" name="tgi_pieslice">, +<ref id="tgi_setcolor" name="tgi_setcolor"> +<tag/Example/<verb> +tgi_setcolor(TGI_COLOR_RED); +tgi_ellipse (50, 40, 40, 20); +</verb> +</descrip> +</quote> + + +<sect1>tgi_free_vectorfont<label id="tgi_free_vectorfont"><p> + +<quote> +<descrip> +<tag/Function/Free a vector font that was previously loaded into memory. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/void __fastcall__ tgi_free_vectorfont (const tgi_vectorfont* font);/ +<tag/Description/Free a vector font that was previously loaded into memory. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/ +<ref id="tgi_load_vectorfont" name="tgi_load_vectorfont">, +<ref id="tgi_install_vectorfont" name="tgi_install_vectorfont"> +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_getaspectratio<label id="tgi_getaspectratio"><p> + +<quote> <descrip> <tag/Function/Return the pixel aspect ratio. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/unsigned tgi_getaspectratio (void);/ +<tag/Description/The function returns the pixel aspect ratio for the current +driver and display as an 8.8 fixed point value. It may be used to correct +geometric shapes so they look correct on the display. As an example, a circle +with a radius of 100 pixels may look elliptic on some driver/display +combinations if the aspect ratio is not 1.00. +<tag/Notes/<itemize> +<item>The aspect ratio is encoded in the TGI driver which assumes a "standard" +monitor for the given platform. The aspect ratio may be wrong if another +monitor is used. +<item>No TGI function will use the aspect ratio. It is up to the programmer to +make use of it. +<item>The <ref id="tgi_setaspectratio" name="tgi_setaspectratio"> function can +be used to change the aspect ratio for a loaded driver. The value is not reset +by <ref id="tgi_init" name="tgi_init">, so if a driver is linked statically to +an application, switching into and out of graphics mode will not restore the +original aspect ratio. +</itemize> +<tag/Availability/cc65 +<tag/See also/ +<ref id="tgi_setaspectratio" name="tgi_setaspectratio"> +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_getcolor<label id="tgi_getcolor"><p> + +<quote> +<descrip> +<tag/Function/Return the current drawing color. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/unsigned char tgi_getcolor (void);/ +<tag/Description/The actual color is an index to a palette. During tgi_init +you will get a default palette. The number of colors depend on the platform. +All platforms recognize at least TGI_COLOR_BLACK and TGI_COLOR_WHITE. But some +platforms have many more predefined colors. If you paint using TGI_COLOR_GREEN +and then you change the green of the palette to blue using tgi_setpalette then +after this painting in TGI_COLOR_GREEN will actually be blue. +<tag/Availability/cc65 +<tag/See also/Other tgi functions +<tag/Example/<verb> +color = tgi_getcolor(); +</verb> +</descrip> +</quote> + + +<sect1>tgi_getcolorcount<label id="tgi_getcolorcount"><p> + +<quote> +<descrip> +<tag/Function/Get the number of available colors. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/unsigned char tgi_getcolorcount (void);/ +<tag/Description/Tgi platforms use indexed color palettes. This function +returns the number of entries we can use in the palette. +<tag/Availability/cc65 +<tag/See also/Other tgi functions +<tag/Example/<verb> +if (tgi_getcolorcount() == 2) { + printf("Only monochrome graphics is supported\n"); +} +</verb> +</descrip> +</quote> + + +<sect1>tgi_getdefpalette<label id="tgi_getdefpalette"><p> + +<quote> +<descrip> +<tag/Function/Get the palette installed by default. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/const unsigned char* tgi_getdefpalette (void);/ +<tag/Description/The tgi driver has a default palette that is active at startup. +The named colors TGI_COLOR_BLACK, TGI_COLOR_WHITE, TGI_COLOR_RED... need this +palette to work correctly. +<tag/Availability/cc65 +<tag/See also/Other tgi functions +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_geterror<label id="tgi_geterror"><p> + +<quote> +<descrip> +<tag/Function/Return the error code for the last operation. +This will also clear the error. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/unsigned char tgi_geterror (void);/ +<tag/Description/Return the error code for the last operation. +This will also clear the error. +<tag/Availability/cc65 +<tag/See also/Other tgi functions +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_geterrormsg<label id="tgi_geterrormsg"><p> + +<quote> +<descrip> +<tag/Function/Get an error message describing the error. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/const char* __fastcall__ tgi_geterrormsg (unsigned char code);/ +<tag/Description/Get an error message describing the error. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/Other tgi functions +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_getmaxcolor<label id="tgi_getmaxcolor"><p> + +<quote> +<descrip> +<tag/Function/Get the highest index of the palette. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/unsigned char tgi_getmaxcolor (void);/ +<tag/Description/Get the highest index of the palette. +<tag/Availability/cc65 +<tag/See also/Other tgi functions +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_getmaxx<label id="tgi_getmaxx"><p> + +<quote> +<descrip> +<tag/Function/Get the maximum x coordinate that can be used on this screen. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/unsigned tgi_getmaxx (void);/ +<tag/Description/Get the maximum x coordinate that can be used on this screen. +<tag/Availability/cc65 +<tag/See also/Other tgi functions +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_getmaxy<label id="tgi_getmaxy"><p> + +<quote> +<descrip> +<tag/Function/Get the maximum y coordinate that can be used on this screen. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/unsigned tgi_getmaxy (void);/ +<tag/Description/Get the maximum y coordinate that can be used on this screen. +<tag/Availability/cc65 +<tag/See also/Other tgi functions +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_getpagecount<label id="tgi_getpagecount"><p> + +<quote> +<descrip> +<tag/Function/Return the number of screen pages available. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/unsigned tgi_getpagecount (void);/ +<tag/Description/Return the number of screen pages available. +<tag/Availability/cc65 +<tag/See also/ +<ref id="tgi_setdrawpage" name="tgi_setdrawpage">, +<ref id="tgi_setviewpage" name="tgi_setviewpage"> +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_getpalette<label id="tgi_getpalette"><p> + +<quote> +<descrip> +<tag/Function/Get the palette installed. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/const unsigned char* tgi_getpalette (void);/ +<tag/Description/Get the palette installed. +<tag/Availability/cc65 +<tag/See also/Other tgi functions +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_getpixel<label id="tgi_getpixel"><p> + +<quote> +<descrip> +<tag/Function/Get the color of a pixel from the viewpage. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/unsigned char __fastcall__ tgi_getpixel (int x, int y);/ +<tag/Description/Get the color of a pixel from the viewpage. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/Other tgi functions. +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_gettextheight<label id="tgi_gettextheight"><p> + +<quote> +<descrip> +<tag/Function/Calculate the height of the text in pixels according to +the current text style. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextheight (const char* s);/ +<tag/Description/Calculate the height of the text in pixels according to +the current text style. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/Other tgi functions. +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_gettextwidth<label id="tgi_gettextwidth"><p> + +<quote> +<descrip> +<tag/Function/Calculate the width of the text in pixels according to the current text style. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/unsigned __fastcall__ tgi_gettextwidth (const char* s);/ +<tag/Description/Calculate the width of the text in pixels according to the current text style. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/Other tgi functions. +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_getxres<label id="tgi_getxres"><p> + +<quote> +<descrip> +<tag/Function/Get number of horisontal pixels on the screen. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/unsigned tgi_getxres (void);/ +<tag/Description/Get number of horisontal pixels on the screen. +This is same as tgi_maxx()+1. +<tag/Availability/cc65 +<tag/See also/Other tgi functions. +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_getyres<label id="tgi_getyres"><p> + +<quote> +<descrip> +<tag/Function/Get number of vertical pixels on the screen. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/unsigned tgi_getyres (void);/ +<tag/Description/Get number of vertical pixels on the screen. +This is same as tgi_maxy()+1. +<tag/Availability/cc65 +<tag/See also/Other tgi functions. +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_gotoxy<label id="tgi_gotoxy"><p> + +<quote> +<descrip> +<tag/Function/Set graphics cursor at x, y. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/void __fastcall__ tgi_gotoxy (int x, int y);/ +<tag/Description/Set graphics cursor at x, y. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/Other tgi functions. +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_init<label id="tgi_init"><p> + +<quote> +<descrip> +<tag/Function/Initialize the already loaded graphics driver. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/void tgi_init (void);/ +<tag/Description/The tgi_init function will set the default palette to the +hardware. +<tag/Notes/<itemize> +<item><tt/tgi_init/ will not clear the screen. This allows switching between +text and graphics mode on platforms that have separate memory areas for the +screens. If you want the screen cleared, call <tt/<ref id="tgi_clear" +name="tgi_clear">/ after <tt/tgi_init/. +</itemize> +<tag/Availability/cc65 +<tag/See also/Other tgi functions. +<tag/Example/<verb> +tgi_install(tgi_static_stddrv); //Include the driver statically instead of loading it. +tgi_init(); //Set up the default palette and clear the screen. +</verb> +</descrip> +</quote> + + +<sect1>tgi_install<label id="tgi_install"><p> + +<quote> +<descrip> +<tag/Function/Install an already loaded driver and return an error code. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/unsigned char __fastcall__ tgi_install (void* driver);/ +<tag/Description/The function installs a driver that was already loaded into +memory (or linked statically to the program). It returns an error code +(<tt/TGI_ERR_OK/ in case of success). +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only be +used in presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/ +<ref id="tgi_load_driver" name="tgi_load_driver">, +<ref id="tgi_uninstall" name="tgi_uninstall">, +<ref id="tgi_unload" name="tgi_unload"> +<tag/Example/<verb> +tgi_install(tgi_static_stddrv); //Include the driver statically instead of loading it. +tgi_init(); //Set up the default palette and clear the screen. +</verb> +</descrip> +</quote> + + +<sect1>tgi_install_vectorfont<label id="tgi_install_vectorfont"><p> + +<quote> +<descrip> +<tag/Function/Install an already loaded driver and return an error code. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/void __fastcall__ tgi_install_vectorfont (const tgi_vectorfont* font);/ +<tag/Description/ +Install a vector font for use. More than one vector font can be loaded, +but only one can be active. This function is used to tell which one. Call +with a NULL pointer to uninstall the currently installed font. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only be +used in presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/ +<ref id="tgi_load_vectorfont" name="tgi_load_vectorfont">, +<ref id="tgi_free_vectorfont" name="tgi_free_vectorfont"> +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_ioctl<label id="tgi_ioctl"><p> + +<quote> +<descrip> +<tag/Function/Platform dependent code extensions. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/unsigned __fastcall__ tgi_ioctl (unsigned char code, void* data);/ +<tag/Description/Some platforms have extra display hardware that is not +supported by standard tgi functions. You can extend the driver to support +this extra hardware using tgi_ioctl functions. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +<item>These functions are not easily portable to other cc65 platforms. +</itemize> +<tag/Availability/cc65 +<tag/See also/Other tgi functions. +<tag/Example/<verb> +#define tgi_sprite(spr) tgi_ioctl(0, (void*)(spr)) +#define tgi_flip() tgi_ioctl(1, (void*)0) +#define tgi_setbgcolor(bgcol) tgi_ioctl(2, (void*)(bgcol)) +#define tgi_setframerate(rate) tgi_ioctl(3, (void*)(rate)) +#define tgi_busy() tgi_ioctl(4, (void*)0) +#define tgi_updatedisplay() tgi_ioctl(4, (void*)1) +if (!tgi_busy()) { + tgi_sprite(&background); + tgi_setcolor(TGI_COLOR_BLUE); + tgi_outttextxy(20,40,"Hello World"); + tgi_updatedisplay(); +} +</verb> +</descrip> +</quote> + + +<sect1>tgi_line<label id="tgi_line"><p> + +<quote> +<descrip> +<tag/Function/Draw a line in the current drawing color. +The graphics cursor will be set to x2/y2 by this call. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/void __fastcall__ tgi_line (int x1, int y1, int x2, int y2);/ +<tag/Description/Draw a line in the current drawing color. +The graphics cursor will be set to x2/y2 by this call. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/Other tgi functions. +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_lineto<label id="tgi_lineto"><p> + +<quote> +<descrip> +<tag/Function/Draw a line in the current drawing color from the graphics +cursor to the new end point. The graphics cursor will be updated to x2/y2. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/void __fastcall__ tgi_lineto (int x2, int y2);/ +<tag/Description/Draw a line in the current drawing color from the graphics +cursor to the new end point. The graphics cursor will be updated to x2/y2. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/Other tgi functions. +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_load_driver<label id="tgi_load_driver"><p> + +<quote> +<descrip> +<tag/Function/Load and install the given driver. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/void __fastcall__ tgi_load_driver (const char *name);/ +<tag/Description/Load and install the driver by name. +Will just load the driver and check if loading was successful. +Will not switch to graphics mode. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/Other tgi functions. +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_load_vectorfont<label id="tgi_load_vectorfont"><p> + +<quote> +<descrip> +<tag/Function/Load the given vector font. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/const tgi_vectorfont* __fastcall__ tgi_load_vectorfont (const char* name);/ +<tag/Description/ +Load a vector font into memory and return it. In case of errors, NULL is +returned and an error is set, which can be retrieved using tgi_geterror. +To use the font, it has to be installed using tgi_install_vectorfont. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/ +<ref id="tgi_install_vectorfont" name="tgi_install_vectorfont">, +<ref id="tgi_free_vectorfont" name="tgi_free_vectorfont"> +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_outtext<label id="tgi_outtext"><p> + +<quote> +<descrip> +<tag/Function/Output text at the current graphics cursor position. +The graphics cursor is moved to the end of the text. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/void __fastcall__ tgi_outtext (const char* s);/ +<tag/Description/Output text at the current graphics cursor position. +The graphics cursor is moved to the end of the text. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/Other tgi functions. +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_outtextxy<label id="tgi_outtextxy"><p> + +<quote> +<descrip> +<tag/Function/Output text at the given cursor position. +The graphics cursor is moved to the end of the text. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/void __fastcall__ tgi_outtextxy (int x, int y, const char* s);/ +<tag/Description/Output text at the given cursor position. +The graphics cursor is moved to the end of the text. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/Other tgi functions. +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_pieslice<label id="tgi_pieslice"><p> + +<quote> +<descrip> +<tag/Function/Draw an elliptic pie slice in the current color. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/void __fastcall__ tgi_pie slice (int x, int y, +unsigned char rx, unsigned char ry, unsigned sa, unsigned ea);/ +<tag/Description/The function draws an elliptic pie slice with center at x/y +and radii rx/ry using the current drawing color. The pie slice covers the angle +between sa and ea (startangle and endangle), which must be in the range +0..360. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +<item>The function behaves unexpectedly or may crash if the angles are out +of range. +</itemize> +<tag/Availability/cc65 +<tag/See also/ +<ref id="tgi_bar" name="tgi_arc">, +<ref id="tgi_bar" name="tgi_bar">, +<ref id="tgi_circle" name="tgi_circle">, +<ref id="tgi_ellipse" name="tgi_ellipse">, +<ref id="tgi_setcolor" name="tgi_setcolor"> +<tag/Example/<verb> +/* Draw the closed upper half of an ellipse */ +tgi_setcolor(TGI_COLOR_BLUE); +tgi_pieslice (50, 50, 40, 20, 0, 180); +</verb> +</descrip> +</quote> + + +<sect1>tgi_setaspectratio<label id="tgi_setaspectratio"><p> + +<quote> <descrip> <tag/Function/Set the pixel aspect ratio. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/void __fastcall__ tgi_setaspectratio (unsigned ratio);/ +<tag/Description/The function sets the pixel aspect ratio for the current +driver and display. The argument is an 8.8 fixed point value. The aspect ratio +may be used to correct geometric shapes so they look correct on a given +display. As an example, a circle with a radius of 100 pixels may look elliptic +on some driver/display combinations if the aspect ratio is not 1.00. +<tag/Notes/<itemize> +<item>The aspect ratio is encoded in the TGI driver which assumes a "standard" +monitor for the given platform. The aspect ratio may be wrong if another +monitor is used. +<item>No TGI function will use the aspect ratio. It is up to the programmer to +make use of it. +<item>The <tt/tgi_setaspectratio/ function can be used to change the aspect +ratio for a loaded driver. The value is not reset by <ref id="tgi_init" +name="tgi_init">, so if a driver is linked statically to an application, +switching into and out of graphics mode will not restore the original aspect +ratio. +<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/See also/ +<ref id="tgi_getaspectratio" name="tgi_getaspectratio"> +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_setcolor<label id="tgi_setcolor"><p> + +<quote> +<descrip> +<tag/Function/Set color to be used in future draw operations. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/void __fastcall__ tgi_setcolor (unsigned char color);/ +<tag/Description/Set color to be used in future draw operations. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/Other tgi functions. +<tag/Example/<verb> +tgi_setcolor(TGI_COLOR_BLACK); +tgi_bar(0,0,30,30); +tgi_setcolor(TGI_COLOR_WHITE); +tgi_bar(10,10,20,20); +</verb> +</descrip> +</quote> + + +<sect1>tgi_setdrawpage<label id="tgi_setdrawpage"><p> + +<quote> +<descrip> +<tag/Function/Set the page for drawing. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/void __fastcall__ tgi_setdrawpage (unsigned char page);/ +<tag/Description/If the drawpage and the viewpage are the same then all drawing +is seen immediately as it is drawn. For double buffered games you can set the +drawpage to a different page than the viewpage. This lets you draw the next +screen in the background and when the screen is ready you display it. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/Other tgi functions. +<tag/Example/<verb> +tgi_setdrawpage(1); +tgi_outtextxy(10, 10, "Hello World"); +tgi_setviewpage(1); // Show page 1 +tgi_setdrawpage(0); +tgi_outtextxy(10, 10, "Creating next frame"); +... +tgi_setviewpage(0); // Show page 0 +</verb> +</descrip> +</quote> + + +<sect1>tgi_setpalette<label id="tgi_setpalette"><p> + +<quote> +<descrip> +<tag/Function/Set the palette (not available with all drivers/hardware). +Palette is a pointer to as many entries as there are colors. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/void __fastcall__ tgi_setpalette (const unsigned char* palette);/ +<tag/Description/Set the palette (not available with all drivers/hardware). +Palette is a pointer to as many entries as there are colors. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/Other tgi functions. +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_setpixel<label id="tgi_setpixel"><p> + +<quote> +<descrip> +<tag/Function/Plot a pixel on the drawpage with the current color. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/void __fastcall__ tgi_setpixel (int x, int y);/ +<tag/Description/Plot a pixel on the drawpage with the current color. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/Other tgi functions. +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_settextscale<label id="tgi_settextscale"><p> + +<quote> +<descrip> +<tag/Function/Set the scaling for text output. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/void __fastcall__ tgi_settextscale (unsigned width, unsigned height);/ +<tag/Description/ +Set the scaling for text output. The scaling factors for width and height +are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/ +<ref id="tgi_settextstyle" name="tgi_settextstyle"> +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_settextstyle<label id="tgi_settextstyle"><p> + +<quote> +<descrip> +<tag/Function/Set the style for text output. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/void __fastcall__ tgi_settextstyle (unsigned char magx, unsigned char magy, unsigned char dir, unsigned char font);/ +<tag/Description/Set the style for text output. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/ +<ref id="tgi_settextscale" name="tgi_settextscale"> +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_setviewpage<label id="tgi_setviewpage"><p> + +<quote> +<descrip> +<tag/Function/Set page to be visible on screen. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/void __fastcall__ tgi_setviewpage (unsigned char page);/ +<tag/Description/If the drawpage and the viewpage are the same then all drawing +is seen immediately as it is drawn. For double buffered games you can set the +drawpage to a different page than the viewpage. This lets you draw the next +screen in the background and when the screen is ready you display it. +<tag/Notes/<itemize> +<item>The function is only available as fastcall function, so it may only +be used in presence of a prototype. +</itemize> +<tag/Availability/cc65 +<tag/See also/Other tgi functions. +<tag/Example/<verb> +tgi_setdrawpage(1); +tgi_outtextxy(10, 10, "Hello World"); +tgi_setviewpage(1); // Show page 1 +tgi_setdrawpage(0); +tgi_outtextxy(10, 10, "Creating next frame"); +... +tgi_setviewpage(0); // Show page 0 +</verb> +</descrip> +</quote> + + +<sect1>tgi_uninstall<label id="tgi_uninstall"><p> + +<quote> +<descrip> +<tag/Function/Uninstall the currently loaded driver but do not unload it. +Will call tgi_done if necessary. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/void tgi_uninstall (void);/ +<tag/Description/Uninstall the currently loaded driver but do not unload it. +Will call tgi_done if necessary. +<tag/Availability/cc65 +<tag/See also/Other tgi functions. +<tag/Example/None. +</descrip> +</quote> + + +<sect1>tgi_unload<label id="tgi_unload"><p> + +<quote> +<descrip> +<tag/Function/Uninstall, then unload the currently loaded driver. +Will call tgi_done if necessary. +<tag/Header/<tt/<ref id="tgi.h" name="tgi.h">/ +<tag/Declaration/<tt/void tgi_unload (void);/ +<tag/Description/Uninstall, then unload the currently loaded driver. +Will call tgi_done if necessary. +<tag/Availability/cc65 +<tag/See also/Other tgi functions. +<tag/Example/None. +</descrip> +</quote> + + +</article> diff --git a/doc/using-make.sgml b/doc/using-make.sgml index 0c3c13a6e..e0e99a99c 100644 --- a/doc/using-make.sgml +++ b/doc/using-make.sgml @@ -58,7 +58,7 @@ SOURCES = foo.c bar.c PROGRAM = foobar ifdef CC65_TARGET -CC = $(CC65_HOME)/bin/cl65 +CC = cl65 CFLAGS = -t $(CC65_TARGET) --create-dep $(<:.c=.d) -O LDFLAGS = -t $(CC65_TARGET) -m $(PROGRAM).map else @@ -104,12 +104,6 @@ best done on the GNU Make command line like this: make CC65_TARGET=c64 </verb></tscreen> -The sample Makefile presumes the variable <tt/CC65_HOME/ to point to the -directory cc65 is located in. Again there are several ways to define this -variable but as its value typically won't change often it is best done as an -environment variable. On Windows the cc65 .exe installer package takes care -of creating a <tt/CC65_HOME/ environment variable. - <sect1>Understanding the sample Makefile<p> diff --git a/doc/vic20.sgml b/doc/vic20.sgml index 26a4aa558..a61691733 100644 --- a/doc/vic20.sgml +++ b/doc/vic20.sgml @@ -6,7 +6,7 @@ <author> <url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline> <url url="mailto:polluks@sdf.lonestar.org" name="Stefan A. Haubenthal"> -<date>2017-05-18 +<date>2018-04-20 <abstract> An overview over the VIC20 runtime system as it is implemented for the cc65 C @@ -147,7 +147,19 @@ No graphics drivers are currently available for the VIC20. <sect1>Extended memory drivers<p> -No extended memory drivers are currently available for the VIC20. +<descrip> + + <tag><tt/vic20-rama.emd (vic20_rama_emd)/</tag> + A driver for any RAM at $A000-$BFFF. Supports 32 256 byte pages. + Written and contributed by Marco van den Heuvel. + + <tag><tt/vic20-georam.emd (vic20_georam_emd)/</tag> + A driver for the Berkeley Softworks GeoRam cartridge connected by means of + the MasC=erade c64 cartridge adapter. The driver will determine the + available RAM from the connected cartridge. It supports 64KB + up to 2048KB of RAM. + +</descrip><p> <sect1>Joystick drivers<p> @@ -161,8 +173,8 @@ The default drivers, <tt/joy_stddrv (joy_static_stddrv)/, point to <tt/vic20-std <tag><tt/vic20-ptvjoy.joy (vic20_ptvjoy_joy)/</tag> Driver for the Protovision 4-player adapter contributed by Groepaz. See - <url url="http://www.protovision-online.de/hardw/4_player.php?language=en" - name="Protovision shop"> for prices and building instructions. Up to three + <url url="https://www.protovision.games/hardw/4_player.php" + name="the Protovision shop"> for prices and building instructions. Up to three joysticks are supported. </descrip><p> diff --git a/include/6502.h b/include/6502.h index 31398e5c1..642a608a8 100644 --- a/include/6502.h +++ b/include/6502.h @@ -51,6 +51,10 @@ typedef unsigned size_t; #define CPU_65C02 1 #define CPU_65816 2 #define CPU_4510 3 +#define CPU_65SC02 4 +#define CPU_65CE02 5 +#define CPU_HUC6280 6 +#define CPU_2A0x 7 unsigned char getcpu (void); /* Detect the CPU the program is running on */ diff --git a/include/_gtia.h b/include/_gtia.h index 424628f19..0542efa2f 100644 --- a/include/_gtia.h +++ b/include/_gtia.h @@ -34,63 +34,65 @@ /* Define a structure with the gtia register offsets */ struct __gtia_write { - unsigned char hposp0; /* horizontal position player 0 */ - unsigned char hposp1; /* horizontal position player 1 */ - unsigned char hposp2; /* horizontal position player 2 */ - unsigned char hposp3; /* horizontal position player 3 */ - unsigned char hposm0; /* horizontal position missile 0 */ - unsigned char hposm1; /* horizontal position missile 1 */ - unsigned char hposm2; /* horizontal position missile 2 */ - unsigned char hposm3; /* horizontal position missile 3 */ - unsigned char sizep0; /* size of player 0 */ - unsigned char sizep1; /* size of player 1 */ - unsigned char sizep2; /* size of player 2 */ - unsigned char sizep3; /* size of player 3 */ - unsigned char sizem; /* size of missiles */ - unsigned char grafp0; /* graphics shape player 0 */ - unsigned char grafp1; /* graphics shape player 1 */ - unsigned char grafp2; /* graphics shape player 2 */ - unsigned char grafp3; /* graphics shape player 3 */ - unsigned char grafm; /* graphics shape missiles */ - unsigned char colpm0; /* color player and missile 0 */ - unsigned char colpm1; /* color player and missile 1 */ - unsigned char colpm2; /* color player and missile 2 */ - unsigned char colpm3; /* color player and missile 3 */ - unsigned char colpf0; /* color playfield 0 */ - unsigned char colpf1; /* color playfield 1 */ - unsigned char colpf2; /* color playfield 2 */ - unsigned char colpf3; /* color playfield 3 */ - unsigned char colbk; /* color background */ - unsigned char prior; /* priority selection */ - unsigned char vdelay; /* vertical delay */ - unsigned char gractl; /* stick/paddle latch, p/m control */ - unsigned char hitclr; /* clear p/m collision */ - unsigned char consol; /* console buttons */ + unsigned char hposp0; /* 0x00: horizontal position player 0 */ + unsigned char hposp1; /* 0x01: horizontal position player 1 */ + unsigned char hposp2; /* 0x02: horizontal position player 2 */ + unsigned char hposp3; /* 0x03: horizontal position player 3 */ + unsigned char hposm0; /* 0x04: horizontal position missile 0 */ + unsigned char hposm1; /* 0x05: horizontal position missile 1 */ + unsigned char hposm2; /* 0x06: horizontal position missile 2 */ + unsigned char hposm3; /* 0x07: horizontal position missile 3 */ + unsigned char sizep0; /* 0x08: size of player 0 */ + unsigned char sizep1; /* 0x09: size of player 1 */ + unsigned char sizep2; /* 0x0A: size of player 2 */ + unsigned char sizep3; /* 0x0B: size of player 3 */ + unsigned char sizem; /* 0x0C: size of missiles */ + unsigned char grafp0; /* 0x0D: graphics shape player 0 */ + unsigned char grafp1; /* 0x0E: graphics shape player 1 */ + unsigned char grafp2; /* 0x0F: graphics shape player 2 */ + unsigned char grafp3; /* 0x10: graphics shape player 3 */ + unsigned char grafm; /* 0x11: graphics shape missiles */ + unsigned char colpm0; /* 0x12: color player and missile 0 */ + unsigned char colpm1; /* 0x13: color player and missile 1 */ + unsigned char colpm2; /* 0x14: color player and missile 2 */ + unsigned char colpm3; /* 0x15: color player and missile 3 */ + unsigned char colpf0; /* 0x16: color playfield 0 */ + unsigned char colpf1; /* 0x17: color playfield 1 */ + unsigned char colpf2; /* 0x18: color playfield 2 */ + unsigned char colpf3; /* 0x19: color playfield 3 */ + unsigned char colbk; /* 0x1A: color background */ + unsigned char prior; /* 0x1B: priority selection */ + unsigned char vdelay; /* 0x1C: vertical delay */ + unsigned char gractl; /* 0x1D: stick/paddle latch, p/m control */ + unsigned char hitclr; /* 0x1E: clear p/m collision */ + unsigned char consol; /* 0x1F: builtin speaker */ }; /* Define a structure with the gtia register offsets */ struct __gtia_read { - unsigned char m0pf; /* missile 0 to playfield collision */ - unsigned char m1pf; /* missile 1 to playfield collision */ - unsigned char m2pf; /* missile 2 to playfield collision */ - unsigned char m3pf; /* missile 3 to playfield collision */ - unsigned char p0pf; /* player 0 to playfield collision */ - unsigned char p1pf; /* player 1 to playfield collision */ - unsigned char p2pf; /* player 2 to playfield collision */ - unsigned char p3pf; /* player 3 to playfield collision */ - unsigned char m0pl; /* missile 0 to player collision */ - unsigned char m1pl; /* missile 1 to player collision */ - unsigned char m2pl; /* missile 2 to player collision */ - unsigned char m3pl; /* missile 3 to player collision */ - unsigned char p0pl; /* player 0 to player collision */ - unsigned char p1pl; /* player 1 to player collision */ - unsigned char p2pl; /* player 2 to player collision */ - unsigned char p3pl; /* player 3 to player collision */ - unsigned char trig0; /* joystick trigger 0 */ - unsigned char trig1; /* joystick trigger 1 */ - unsigned char trig2; /* joystick trigger 2 */ - unsigned char trig3; /* joystick trigger 3 */ - unsigned char pal; /* pal/ntsc flag */ + unsigned char m0pf; /* 0x00: missile 0 to playfield collision */ + unsigned char m1pf; /* 0x01: missile 1 to playfield collision */ + unsigned char m2pf; /* 0x02: missile 2 to playfield collision */ + unsigned char m3pf; /* 0x03: missile 3 to playfield collision */ + unsigned char p0pf; /* 0x04: player 0 to playfield collision */ + unsigned char p1pf; /* 0x05: player 1 to playfield collision */ + unsigned char p2pf; /* 0x06: player 2 to playfield collision */ + unsigned char p3pf; /* 0x07: player 3 to playfield collision */ + unsigned char m0pl; /* 0x08: missile 0 to player collision */ + unsigned char m1pl; /* 0x09: missile 1 to player collision */ + unsigned char m2pl; /* 0x0A: missile 2 to player collision */ + unsigned char m3pl; /* 0x0B: missile 3 to player collision */ + unsigned char p0pl; /* 0x0C: player 0 to player collision */ + unsigned char p1pl; /* 0x0D: player 1 to player collision */ + unsigned char p2pl; /* 0x0E: player 2 to player collision */ + unsigned char p3pl; /* 0x0F: player 3 to player collision */ + unsigned char trig0; /* 0x10: joystick trigger 0 */ + unsigned char trig1; /* 0x11: joystick trigger 1 */ + unsigned char trig2; /* 0x12: joystick trigger 2 */ + unsigned char trig3; /* 0x13: joystick trigger 3 */ + unsigned char pal; /* 0x14: pal/ntsc flag */ + unsigned char unused[10]; + unsigned char consol; /* 0x1F: console buttons */ }; /* End of _gtia.h */ diff --git a/include/accelerator.h b/include/accelerator.h new file mode 100644 index 000000000..fdd2ebaf7 --- /dev/null +++ b/include/accelerator.h @@ -0,0 +1,309 @@ +/*****************************************************************************/ +/* */ +/* accelerator.h */ +/* */ +/* Accelerator specific definitions */ +/* */ +/* */ +/* */ +/* (C) 2018 Marco van den Heuvel */ +/* EMail: blackystardust68@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 _ACCELERATOR_H +#define _ACCELERATOR_H + +/*****************/ +/* Speed defines */ +/*****************/ + +#define SPEED_SLOW 0x00 +#define SPEED_FAST 0xFF + +#define SPEED_1X SPEED_SLOW +#define SPEED_2X 2 - 1 /* C64 Chameleon, C64DTV, C128, PET 65816, Apple2 Fast Chip, Apple2 TransWarp, Apple2 Zip Chip */ +#define SPEED_3X 3 - 1 /* C64 Chameleon, C65, PET 65816, Apple2 Booster, Apple 2 Fast Chip, Apple2 Titan, Apple2 TransWarp, Apple2 Zip Chip */ +#define SPEED_4X 4 - 1 /* C64 Chameleon, C64 TurboMaster, C64 TurboProcess, PET 65816, Apple2 Fast Chip, Apple2 Zip Chip */ +#define SPEED_5X 5 - 1 /* C64 Chameleon, PET 65816, Apple2 Fast Chip */ +#define SPEED_6X 6 - 1 /* C64 Chameleon, PET 65816, Apple2 Fast Chip */ +#define SPEED_7X 7 - 1 /* PET 65816, Apple2 Fast Chip */ +#define SPEED_8X 8 - 1 /* C64 Flash8, PET 65816, Apple 2 Fast Chip */ +#define SPEED_10X 10 - 1 /* PET 65816, Apple2 Fast Chip */ +#define SPEED_12X 12 - 1 /* Apple2 Fast Chip */ +#define SPEED_16X 16 - 1 /* Apple2 Fast Chip */ +#define SPEED_20X 20 - 1 /* C64/C128 SuperCPU */ + +/***********************************/ +/* Accelerator function prototypes */ +/***********************************/ + +/* C64/C128 SuperCPU cartridge */ + +unsigned char __fastcall__ set_scpu_speed (unsigned char speed); + +/* Set the speed of the SuperCPU cartridge, using SPEED_SLOW will switch to + * 1 Mhz mode, SPEED_20X or SPEED_FAST will switch to 20 Mhz mode. + * + * Note that any value lower than SPEED_20X will switch to 1 Mhz mode, and + * any value higher or equal to SPEED_20X will switch to 20 Mhz mode. + * + * This function will return the actual speed the CPU is at after trying + * to set the requested speed, if this is not the speed that was requested + * then possibly the hardware speed switch prevented any software speed + * switching. + * + * This function does not check for the presence of the SuperCPU cartridge, + * make sure you use 'detect_scpu();' before using. + */ + +unsigned char get_scpu_speed (void); + +/* Get the speed of the SuperCPU cartridge. + * + * Possible return values: + * SPEED_1X : 1 Mhz mode + * SPEED_20X : 20 Mhz mode + * + * This function does not check for the presence of the SuperCPU cartridge, + * make sure you use 'detect_scpu();' before using. + */ + +unsigned char detect_scpu (void); + +/* Check for the presence of the SuperCPU cartridge. + * + * Possible return values: + * 0x00 : SuperCPU cartridge not present + * 0x01 : SuperCPU cartridge present + */ + + +/* C64DTV */ + +unsigned char __fastcall__ set_c64dtv_speed (unsigned char speed); + +/* Set the speed of the C64DTV, using SPEED_SLOW will switch to + * slow mode, SPEED_2X or SPEED_FAST will switch to fast mode. + * + * Note that any value higher or equal to SPEED_2X will switch to fast mode. + * + * This function will return the actual speed the CPU is at after trying + * to set the requested speed, to my knowledge the switch should not fail. + * + * This function does not check for the presence of the C64DTV, + * make sure you use 'detect_c64dtv();' before using. + */ + +unsigned char get_c64dtv_speed (void); + +/* Get the speed of the C64DTV. + * + * Possible return values: + * SPEED_1X : slow mode + * SPEED_2X : fast mode + * + * This function does not check for the presence of the C64DTV, + * make sure you use 'detect_c64dtv();' before using. + */ + +unsigned char detect_c64dtv (void); + +/* Check for the presence of the C64DTV. + * + * Possible return values: + * 0x00 : C64DTV not present + * 0x01 : C64DTV present + */ + + +/* C128 8502 CPU */ + +unsigned char __fastcall__ set_c128_speed (unsigned char speed); + +/* Set the speed of the C128 8502 CPU, using SPEED_SLOW will switch to + * 1 Mhz (slow) mode, SPEED_2X or SPEED_FAST will switch to 2Mhz (fast) mode. + * + * Note that any value higher or equal to SPEED_2X will switch to fast mode. + * + * This function will return the actual speed the CPU is at after trying + * to set the requested speed, to my knowledge the switching should not fail. + * + * This function does not check if the C128 CPU is the current CPU, make sure + * you use 'detect_c128();' before using. + */ + +unsigned char get_c128_speed (void); + +/* Get the speed of the C128 8502 CPU. + * + * Possible return values: + * SPEED_SLOW : Slow mode + * SPEED_2X : Fast mode + * + * This function does not check if the C128 CPU is the current CPU, make sure + * you use 'detect_c128();' before using. + */ + +unsigned char detect_c128 (void); + +/* Check if the C128 CPU is the current CPU. + * + * Possible return values: + * 0x00 : C128 CPU is not the current CPU + * 0x01 : C128 CPU is the current CPU + */ + + +/* C64 Chameleon cartridge */ + +unsigned char __fastcall__ set_chameleon_speed (unsigned char speed); + +/* Set the speed of the C64 Chameleon cartridge, the following inputs + * are accepted: + * SPEED_SLOW : 1 Mhz mode + * SPEED_1X : 1 Mhz mode + * SPEED_2X : 2 Mhz mode + * SPEED_3X : 3 Mhz mode + * SPEED_4X : 4 Mhz mode + * SPEED_5X : 5 Mhz mode + * SPEED_6X : 6 Mhz mode + * SPEED_FAST : Maximum speed mode + * + * Note that any value higher or equal to SPEED_7X will switch to maximum + * speed mode. + * + * This function will return the actual speed the CPU is at after trying + * to set the requested speed, to my knowledge the switching should not fail. + * + * This function does not check for the presence of the C64 Chameleon cartridge, + * make sure you use 'detect_chameleon();' before using. + */ + +unsigned char get_chameleon_speed (void); + +;/* Get the speed of the C64 Chameleon cartridge. +; * +; * Possible return values: +; * SPEED_SLOW : Slow mode +; * SPEED_2X : 2Mhz mode +; * SPEED_3X : 3Mhz mode +; * SPEED_4X : 4Mhz mode +; * SPEED_5X : 5Mhz mode +; * SPEED_6X : 6Mhz mode +; * SPEED_FAST : Maximum speed mode +; * +; * This function does not check for the presence of the C64 Chameleon cartridge, +; * make sure you use 'detect_chameleon();' before using. +; */ + +unsigned char detect_chameleon (void); + +/* Check for the presence of the C64 Chameleon cartridge. + * + * Possible return values: + * 0x00 : C64 Chameleon cartridge not present + * 0x01 : C64 Chameleon cartridge present + */ + + +/* C65/C64DX in C64 mode */ + +unsigned char __fastcall__ set_c65_speed (unsigned char speed); + +/* Set the speed of the C65/C64DX CPU, using SPEED_SLOW will switch to + * 1 Mhz mode, SPEED_3X or SPEED_FAST will switch to 3.5 Mhz (fast) mode. + * + * Note that any value higher or equal to SPEED_3X will switch to fast mode. + * + * This function will return the actual speed the CPU is at after trying + * to set the requested speed, to my knowledge the switching should not fail. + * + * This function does not check for the presence of a C65/C64DX in C64 mode, + * make sure you use 'detect_c65();' before using. + */ + +unsigned char get_c65_speed (void); + +/* Get the speed of the C65/C64DX CPU. + * + * Possible return values: + * SPEED_SLOW : Slow mode + * SPEED_3X : Fast mode + * + * This function does not check for the presence of a C65/C64DX in C64 mode, + * make sure you use 'detect_c65();' before using. + */ + +unsigned char detect_c65 (void); + +/* Check for the presence of a C65/C64DX in C64 mode. + * + * Possible return values: + * 0x00 : C65/C64DX in C64 mode not present + * 0x01 : C65/C64DX in C64 mode present + */ + + +/* C64 Turbo Master cartridge */ + +unsigned char __fastcall__ set_turbomaster_speed (unsigned char speed); + +/* Set the speed of the Turbo Master cartridge, using SPEED_SLOW will switch to + * 1 Mhz mode, SPEED_4X or SPEED_FAST will switch to 4 Mhz mode. + * + * Note that any value higher or equal to SPEED_4X will switch to 4 Mhz mode, + * any value lower than SPEED_4X will switch to 1 Mhz mode. + * + * This function will return the actual speed the CPU is at after trying + * to set the requested speed, if the speed is different it might indicate + * that the hardware switch has locked the speed. + * + * This function does not check for the presence of a Turbo Master cartridge, + * make sure you use 'detect_turbomaster();' before using. + */ + +unsigned char get_turbomaster_speed (void); + +/* Get the speed of the Turbo Master cartridge. + * + * Possible return values: + * SPEED_SLOW : 1 Mhz mode + * SPEED_4X : 4 Mhz mode + * + * This function does not check for the presence of a Turbo Master cartridge, + * make sure you use 'detect_turbomaster();' before using. + */ + +unsigned char detect_turbomaster (void); + +/* Check for the presence of a C64 Turbo Master cartridge. + * + * Possible return values: + * 0x00 : C64 Turbo Master cartridge not present + * 0x01 : C64 Turbo Master cartridge present + */ + +/* End of accelerator.h */ +#endif + diff --git a/include/ace.h b/include/ace.h deleted file mode 100644 index fba672227..000000000 --- a/include/ace.h +++ /dev/null @@ -1,119 +0,0 @@ -/*****************************************************************************/ -/* */ -/* ace.h */ -/* */ -/* ACE system-specific definitions */ -/* */ -/* */ -/* */ -/* (C) 1998-2015, Ullrich von Bassewitz */ -/* Roemerstrasse 52 */ -/* D-70794 Filderstadt */ -/* EMail: uz@cc65.org */ -/* */ -/* */ -/* 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 _ACE_H -#define _ACE_H - - - -/* Check for errors */ -#if !defined(__ACE__) -# error This module may only be used when compiling for the ACE os! -#endif - - - -#ifndef _STDDEF_H -#include <stddef.h> -#endif - - - -struct aceDirentBuf { - unsigned long ad_size; /* Size in bytes */ - unsigned char ad_date [8]; /* YY:YY:MM:DD:HH:MM:SS:TW */ - char ad_type [4]; /* File type as ASCIIZ string */ - unsigned char ad_flags; /* File flags */ - unsigned char ad_usage; /* More flags */ - unsigned char ad_namelen; /* Length of name */ - char ad_name [17]; /* Name itself, ASCIIZ */ -}; - -int __cdecl__ aceDirOpen (char* dir); -int __cdecl__ aceDirClose (int handle); -int __cdecl__ aceDirRead (int handle, struct aceDirentBuf* buf); - -/* Type of an ACE key. Key in low byte, shift mask in high byte */ -typedef unsigned int aceKey; - -/* #defines for the shift mask returned by aceConGetKey */ -#define aceSH_KEY 0x00FF /* Mask key itself */ -#define aceSH_MASK 0xFF00 /* Mask shift mask */ -#define aceSH_EXT 0x2000 /* Extended key */ -#define aceSH_CAPS 0x1000 /* Caps lock key */ -#define aceSH_ALT 0x0800 /* Alternate key */ -#define aceSH_CTRL 0x0400 /* Ctrl key */ -#define aceSH_CBM 0x0200 /* Commodore key */ -#define aceSH_SHIFT 0x0100 /* Shift key */ - -/* #defines for the options in aceConSetOpt/aceConGetOpt */ -#define aceOP_PUTMASK 1 /* Console put mask */ -#define aceOP_CHARCOLOR 2 /* Character color */ -#define aceOP_CHARATTR 3 /* Character attribute */ -#define aceOP_FILLCOLOR 4 /* Fill color */ -#define aceOP_FILLATTR 5 /* Fill attribute */ -#define aceOP_CRSCOLOR 6 /* Cursor color */ -#define aceOP_CRSWRAP 7 /* Force cursor wrap */ -#define aceOP_SHSCROLL 8 /* Shift keys for scrolling */ -#define aceOP_MOUSCALE 9 /* Mouse scaling */ -#define aceOP_RPTDELAY 10 /* Key repeat delay */ -#define aceOP_RPTRATE 11 /* Key repeat rate */ - -/* Console functions */ -void __cdecl__ aceConWrite (char* buf, size_t count); -void __cdecl__ aceConPutLit (int c); -void __cdecl__ aceConPos (unsigned x, unsigned y); -void __cdecl__ aceConGetPos (unsigned* x, unsigned* y); -unsigned aceConGetX (void); -unsigned aceConGetY (void); -char __cdecl__* aceConInput (char* buf, unsigned initial); -int aceConStopKey (void); -aceKey aceConGetKey (void); -int __cdecl__ aceConKeyAvail (aceKey* key); -void __cdecl__ aceConKeyMat (char* matrix); -void __cdecl__ aceConSetOpt (unsigned char opt, unsigned char val); -int __cdecl__ aceConGetOpt (unsigned char opt); - -/* Misc stuff */ -int __cdecl__ aceMiscIoPeek (unsigned addr); -void __cdecl__ aceMiscIoPoke (unsigned addr, unsigned char val); - - - -/* End of ace.h */ -#endif - - - diff --git a/include/apple2.h b/include/apple2.h index 421b5db6c..f217ad04c 100644 --- a/include/apple2.h +++ b/include/apple2.h @@ -41,9 +41,10 @@ # error This module may only be used when compiling for the Apple ][! #endif - #include <apple2_filetype.h> + + /*****************************************************************************/ /* Data */ /*****************************************************************************/ @@ -134,6 +135,7 @@ extern unsigned char _dos_type; ** ProDOS 8 2.0.1 - 0x21 ** ProDOS 8 2.0.2 - 0x22 ** ProDOS 8 2.0.3 - 0x23 +** ProDOS 8 2.4.x - 0x24 */ diff --git a/include/apple2enh.h b/include/apple2enh.h index cc62f70b7..77328b5ed 100644 --- a/include/apple2enh.h +++ b/include/apple2enh.h @@ -42,10 +42,7 @@ -/* If not already done, include the apple2.h header file */ -#if !defined(_APPLE2_H) -# include <apple2.h> -#endif +#include <apple2.h> diff --git a/include/atari.h b/include/atari.h index bf1af7d7b..4bed8d7a7 100644 --- a/include/atari.h +++ b/include/atari.h @@ -355,5 +355,7 @@ struct __iocb { #define IOCB_GETCWD 0x30 /* get current directory (MyDOS/SpartaDOS) */ #define IOCB_FORMAT 0xFE /* format */ + + /* End of atari.h */ #endif diff --git a/include/atari2600.h b/include/atari2600.h index 1eb51a2dd..a6b5cda47 100644 --- a/include/atari2600.h +++ b/include/atari2600.h @@ -8,9 +8,13 @@ /* */ /*****************************************************************************/ + + #ifndef _ATARI2600_H #define _ATARI2600_H + + /* Check for errors */ #if !defined(__ATARI2600__) # error This module may only be used when compiling for the Atari 2600! @@ -22,5 +26,7 @@ #include <_riot.h> #define RIOT (*(struct __riot*)0x0280) + + /* End of atari2600.h */ -#endif /* #ifndef _ATARI2600_H */ +#endif diff --git a/include/atmos.h b/include/atmos.h index c642f9e2a..d9f6d103b 100644 --- a/include/atmos.h +++ b/include/atmos.h @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 2002 Debrune Jérome, <jede@oric.org> */ +/* (C) 2002 Debrune Jérome, <jede@oric.org> */ /* (C) 2003-2013 Ullrich von Bassewitz */ /* Roemerstrasse 52 */ /* D-70794 Filderstadt */ @@ -129,6 +129,7 @@ /* The addresses of the static drivers */ extern void atmos_pase_joy[]; /* Referred to by joy_static_stddrv[] */ +extern void atmos_ijk_joy[]; extern void atmos_acia_ser[]; extern void atmos_228_200_3_tgi[]; extern void atmos_240_200_2_tgi[]; /* Referred to by tgi_static_stddrv[] */ diff --git a/include/c128.h b/include/c128.h index 356140d41..99e050a9b 100644 --- a/include/c128.h +++ b/include/c128.h @@ -167,7 +167,8 @@ void fast (void); void slow (void); /* Switch the CPU into 1MHz mode. */ - +unsigned char isfast (void); +/* Returns 1 if the CPU is in 2MHz mode. */ /* End of c128.h */ #endif diff --git a/include/c16.h b/include/c16.h index d49ca6fd4..beb2caa56 100644 --- a/include/c16.h +++ b/include/c16.h @@ -45,11 +45,8 @@ -/* Include the base header file for the 264 series. include file. - */ -#ifndef _CBM264_H +/* Include the base header file for the 264 series. */ #include <cbm264.h> -#endif diff --git a/include/cbm.h b/include/cbm.h index a4b232406..1395f700f 100644 --- a/include/cbm.h +++ b/include/cbm.h @@ -46,10 +46,7 @@ /* We need NULL. */ - -#if !defined(_STDDEF_H) -# include <stddef.h> -#endif +#include <stddef.h> /* Load the system-specific files here, if needed. */ #if defined(__C64__) && !defined(_C64_H) @@ -209,6 +206,7 @@ void __fastcall__ cbm_k_setnam (const char* Name); void __fastcall__ cbm_k_talk (unsigned char dev); void cbm_k_udtim (void); void cbm_k_unlsn (void); +void cbm_k_untlk (void); diff --git a/include/cbm264.h b/include/cbm264.h index 46fa64050..5e8a242a7 100644 --- a/include/cbm264.h +++ b/include/cbm264.h @@ -136,11 +136,16 @@ /* Code */ /*****************************************************************************/ +void fast (void); +/* Switch the CPU into double-clock mode. */ + +void slow (void); +/* Switch the CPU into single-clock mode. */ + +unsigned char isfast (void); +/* Returns 1 if the CPU is in double-clock mode. */ + /* End of cbm264.h */ #endif - - - - diff --git a/include/cbm610.h b/include/cbm610.h index 79d498431..de7aa50f8 100644 --- a/include/cbm610.h +++ b/include/cbm610.h @@ -85,7 +85,8 @@ #define SID (*(struct __sid*)0xDA00) #include <_6526.h> -#define CIA (*(struct __6526*)0xDC00) +#define CIA1 (*(struct __6526*)0xDB00) +#define CIA2 (*(struct __6526*)0xDC00) #include <_6551.h> #define ACIA (*(struct __6551*)0xDD00) @@ -144,11 +145,9 @@ void __fastcall__ pokewsys (unsigned addr, unsigned val); #define _textcolor(color) COLOR_WHITE #define _bgcolor(color) COLOR_BLACK #define _bordercolor(color) COLOR_BLACK +#define _cpeekcolor(color) COLOR_WHITE /* End of cbm610.h */ #endif - - - diff --git a/include/conio.h b/include/conio.h index baf55dd08..72421af86 100644 --- a/include/conio.h +++ b/include/conio.h @@ -54,40 +54,8 @@ -#if !defined(_STDARG_H) -# include <stdarg.h> -#endif - -/* Include the correct machine-specific file */ -#if defined(__APPLE2ENH__) -# 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__) -# include <geos.h> -#elif defined(__LUNIX__) -# include <lunix.h> -#elif defined(__LYNX__) -# include <lynx.h> -#elif defined(__NES__) -# include <nes.h> -#elif defined(__OSIC1P__) -# include <osic1p.h> -#elif defined(__PCE__) -# include <pce.h> -#endif +#include <stdarg.h> +#include <target.h> @@ -148,6 +116,23 @@ int cscanf (const char* format, ...); int __fastcall__ vcscanf (const char* format, va_list ap); /* Like vscanf(), but uses direct keyboard input */ +char cpeekc (void); +/* Return the character from the current cursor position */ + +unsigned char cpeekcolor (void); +/* Return the color from the current cursor position */ + +unsigned char cpeekrevers (void); +/* Return the reverse attribute from the current cursor position. +** If the character is reversed, then return 1; return 0 otherwise. +*/ + +void __fastcall__ cpeeks (char* s, unsigned int length); +/* Return a string of the characters that start at the current cursor position. +** Put the string into the buffer to which "s" points. The string will have +** "length" characters, then will be '\0'-terminated. +*/ + unsigned char __fastcall__ cursor (unsigned char onoff); /* If onoff is 1, a cursor is displayed when waiting for keyboard input. If ** onoff is 0, the cursor is hidden when waiting for keyboard input. The @@ -215,15 +200,18 @@ void __fastcall__ cputhex16 (unsigned val); ** the macro will give access to the actual function. */ -#if defined(_textcolor) +#ifdef _textcolor # define textcolor(x) _textcolor(x) #endif -#if defined(_bgcolor) +#ifdef _bgcolor # define bgcolor(x) _bgcolor(x) #endif -#if defined(_bordercolor) +#ifdef _bordercolor # define bordercolor(x) _bordercolor(x) #endif +#ifdef _cpeekcolor +# define cpeekcolor(x) _cpeekcolor(x) +#endif diff --git a/include/device.h b/include/device.h index 68b1c807a..b0a5f5e76 100644 --- a/include/device.h +++ b/include/device.h @@ -35,6 +35,13 @@ +#ifndef _HAVE_size_t +typedef unsigned size_t; +#define _HAVE_size_t +#endif + + + /*****************************************************************************/ /* Data */ /*****************************************************************************/ diff --git a/include/dirent.h b/include/dirent.h index b5e1be135..124c7f224 100644 --- a/include/dirent.h +++ b/include/dirent.h @@ -107,7 +107,7 @@ struct dirent { #define _DE_ISREG(t) (((t) & _CBM_T_REG) != 0) #define _DE_ISDIR(t) ((t) == _CBM_T_DIR) -#define _DE_ISLBL(t) ((t) == _CBM_T_HDR) +#define _DE_ISLBL(t) ((t) == _CBM_T_HEADER) #define _DE_ISLNK(t) ((t) == _CBM_T_LNK) #elif defined(__LYNX__) diff --git a/include/geos.h b/include/geos.h index ae356d679..3f760b6ad 100644 --- a/include/geos.h +++ b/include/geos.h @@ -19,53 +19,19 @@ -#ifndef _GCONST_H #include <geos/gconst.h> -#endif - -#ifndef _GSTRUCT_H #include <geos/gstruct.h> -#endif - -#ifndef _GSYM_H #include <geos/gsym.h> -#endif - -#ifndef _GDISK_H #include <geos/gdisk.h> -#endif - -#ifndef _GFILE_H #include <geos/gfile.h> -#endif - -#ifndef _GPROCESS_H #include <geos/gprocess.h> -#endif - -#ifndef _GGRAPH_H #include <geos/ggraph.h> -#endif - -#ifndef _GMENU_H #include <geos/gmenu.h> -#endif - -#ifndef _GSPRITE_H #include <geos/gsprite.h> -#endif - -#ifndef _GMEMORY_H #include <geos/gmemory.h> -#endif - -#ifndef _GSYS_H #include <geos/gsys.h> -#endif - -#ifndef _GDLGBOX_H #include <geos/gdlgbox.h> -#endif + #define CH_ULCORNER '+' @@ -140,5 +106,6 @@ #define JOY_BTN_1_MASK 0x10 + /* End of geos.h */ #endif diff --git a/include/geos/gdisk.h b/include/geos/gdisk.h index f65d7d301..30305a2fc 100644 --- a/include/geos/gdisk.h +++ b/include/geos/gdisk.h @@ -7,9 +7,7 @@ #ifndef _GDISK_H #define _GDISK_H -#ifndef _GSTRUCT_H #include <geos/gstruct.h> -#endif char __fastcall__ ReadBuff(struct tr_se *myTrSe); char __fastcall__ WriteBuff(struct tr_se *myTrSe); diff --git a/include/geos/gfile.h b/include/geos/gfile.h index d7667d8ec..ec7a75bbc 100644 --- a/include/geos/gfile.h +++ b/include/geos/gfile.h @@ -7,9 +7,7 @@ #ifndef _GFILE_H #define _GFILE_H -#ifndef _GSTRUCT_H #include <geos/gstruct.h> -#endif struct filehandle *Get1stDirEntry(void); struct filehandle *GetNxtDirEntry(void); diff --git a/include/geos/ggraph.h b/include/geos/ggraph.h index 961ec2d80..35e02c198 100644 --- a/include/geos/ggraph.h +++ b/include/geos/ggraph.h @@ -7,9 +7,7 @@ #ifndef _GGRAPH_H #define _GGRAPH_H -#ifndef _GSTRUCT_H #include <geos/gstruct.h> -#endif void __fastcall__ SetPattern(char newpattern); diff --git a/include/geos/gmemory.h b/include/geos/gmemory.h index 3fba5cb5b..ba8e9f211 100644 --- a/include/geos/gmemory.h +++ b/include/geos/gmemory.h @@ -7,9 +7,7 @@ #ifndef _GMEMORY_H #define _GMEMORY_H -#ifndef _GSTRUCT_H #include <geos/gstruct.h> -#endif void __fastcall__ CopyString(char *dest, const char *source); char __fastcall__ CmpString(const char *dest, const char *source); diff --git a/include/geos/gmenu.h b/include/geos/gmenu.h index 3175b6cf3..89caa2c02 100644 --- a/include/geos/gmenu.h +++ b/include/geos/gmenu.h @@ -7,9 +7,7 @@ #ifndef _GMENU_H #define _GMENU_H -#ifndef _GSTRUCT_H #include <geos/gstruct.h> -#endif void __fastcall__ DoMenu(struct menu *myMenu); void ReDoMenu(void); diff --git a/include/geos/gprocess.h b/include/geos/gprocess.h index 6fab2ecfa..000003f32 100644 --- a/include/geos/gprocess.h +++ b/include/geos/gprocess.h @@ -7,9 +7,7 @@ #ifndef _GPROCESS_H #define _GPROCESS_H -#ifndef _GSTRUCT_H #include <geos/gstruct.h> -#endif void __fastcall__ InitProcesses(char number, struct process *proctab); void __fastcall__ RestartProcess(char number); diff --git a/include/geos/gsym.h b/include/geos/gsym.h index 085046674..2b2c8fbb2 100644 --- a/include/geos/gsym.h +++ b/include/geos/gsym.h @@ -7,9 +7,7 @@ #ifndef _GSYM_H #define _GSYM_H -#ifndef _GSTRUCT_H #include <geos/gstruct.h> -#endif #define r0 (*(unsigned*)(R_BASE + 0x00)) #define r0L (*(char*)(R_BASE + 0x00)) diff --git a/include/geos/gsys.h b/include/geos/gsys.h index 284c38b63..1753492e5 100644 --- a/include/geos/gsys.h +++ b/include/geos/gsys.h @@ -31,9 +31,13 @@ char get_ostype(void); #define GEOS4 0x04 /* plus4 geos is not or'ed with version */ #define GEOS128 0x80 /* version flags */ +#define MEGAPATCH3 0x03 +#define GATEWAY 0x08 #define GEOS_V10 0x10 #define GEOS_V11 0x11 -#define GEOS_V12 0x12 /* ??? not sure */ +#define GEOS_V12 0x12 +#define GEOS_V13 0x13 +#define GEOS_V15 0x15 #define GEOS_V20 0x20 #define WHEELS 0x40 /* only Wheels? */ diff --git a/include/joystick.h b/include/joystick.h index 26f339fe4..b6771c381 100644 --- a/include/joystick.h +++ b/include/joystick.h @@ -38,6 +38,10 @@ +#include <target.h> + + + /*****************************************************************************/ /* Definitions */ /*****************************************************************************/ @@ -103,6 +107,3 @@ unsigned char __fastcall__ joy_read (unsigned char joystick); /* End of joystick.h */ #endif - - - diff --git a/include/joystick/joy-kernel.h b/include/joystick/joy-kernel.h index e984291f7..783508247 100644 --- a/include/joystick/joy-kernel.h +++ b/include/joystick/joy-kernel.h @@ -59,7 +59,6 @@ typedef struct { void* uninstall; /* UNINSTALL routine */ void* count; /* COUNT routine */ void* read; /* READ routine */ - void* irq; /* IRQ routine */ } joy_drv_header; diff --git a/include/lynx.h b/include/lynx.h index 3629f322e..4b0390a13 100644 --- a/include/lynx.h +++ b/include/lynx.h @@ -123,6 +123,8 @@ extern void lynx_160_102_16_tgi[]; /* Referred to by tgi_static_stddrv[] */ /* Sound support */ /*****************************************************************************/ + + void lynx_snd_init (void); /* Initialize the sound driver */ @@ -144,6 +146,8 @@ void __fastcall__ lynx_snd_stop_channel (unsigned char channel); unsigned char lynx_snd_active(void); /* Show which channels are active */ + + /*****************************************************************************/ /* Accessing the cart */ /*****************************************************************************/ @@ -209,5 +213,6 @@ unsigned __fastcall__ lynx_eewrite (unsigned cell, unsigned val); #define SUZY (*(struct __suzy*)0xFC00) + /* End of lynx.h */ #endif diff --git a/include/pet.h b/include/pet.h index e9659d524..249d8b608 100644 --- a/include/pet.h +++ b/include/pet.h @@ -105,6 +105,7 @@ extern void pet_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */ #define _textcolor(color) COLOR_WHITE #define _bgcolor(color) COLOR_BLACK #define _bordercolor(color) COLOR_BLACK +#define _cpeekcolor(color) COLOR_WHITE diff --git a/include/plus4.h b/include/plus4.h index 840e8b342..c8aaf2eaf 100644 --- a/include/plus4.h +++ b/include/plus4.h @@ -45,11 +45,8 @@ -/* Include the base header file for the 264 series. include file. - */ -#ifndef _CBM264_H +/* Include the base header file for the 264 series. */ #include <cbm264.h> -#endif /* Define hardware */ #include <_6551.h> diff --git a/include/stdio.h b/include/stdio.h index a3facd513..73dc05bdb 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -38,12 +38,8 @@ -#ifndef _STDDEF_H -# include <stddef.h> -#endif -#ifndef _STDARG_H -# include <stdarg.h> -#endif +#include <stddef.h> +#include <stdarg.h> @@ -147,6 +143,3 @@ void __fastcall__ _poserror (const char* msg); /* cc65 */ /* End of stdio.h */ #endif - - - diff --git a/include/supervision.h b/include/supervision.h index ffece4ecb..cce037910 100644 --- a/include/supervision.h +++ b/include/supervision.h @@ -54,28 +54,28 @@ struct __sv_lcd { unsigned char xpos; unsigned char ypos; }; -#define SV_LCD ((struct __sv_lcd*)0x2000) +#define SV_LCD (*(struct __sv_lcd*)0x2000) struct __sv_tone { unsigned delay; unsigned char control; unsigned char timer; }; -#define SV_RIGHT ((struct __sv_tone*)0x2010) -#define SV_LEFT ((struct __sv_tone*)0x2014) +#define SV_RIGHT (*(struct __sv_tone*)0x2010) +#define SV_LEFT (*(struct __sv_tone*)0x2014) struct __sv_noise { unsigned char volume; /* and frequency */ unsigned char timer; unsigned char control; }; -#define SV_NOISE ((struct __sv_noise*)0x2028) +#define SV_NOISE (*(struct __sv_noise*)0x2028) struct __io_port { unsigned char in; unsigned char out; }; -#define IO_PORT ((struct __io_port*)(0x2021) +#define IO_PORT (*(struct __io_port*)0x2021) struct __sv_dma { unsigned start; @@ -83,7 +83,7 @@ struct __sv_dma { unsigned char control; unsigned char on; }; -#define SV_DMA ((struct __sv_dma*)0x2018) +#define SV_DMA (*(struct __sv_dma*)0x2018) #define SV_CONTROL (*(unsigned char*)0x2020) @@ -105,9 +105,33 @@ extern unsigned char sv_nmi_counter; extern unsigned char sv_timer_irq_counter; extern unsigned char sv_timer_dma_counter; +/* Masks for joy_read */ +#define JOY_UP_MASK 0x08 +#define JOY_DOWN_MASK 0x04 +#define JOY_LEFT_MASK 0x02 +#define JOY_RIGHT_MASK 0x01 +#define JOY_BTN_1_MASK 0x20 +#define JOY_BTN_2_MASK 0x10 +#define JOY_BTN_3_MASK 0x80 +#define JOY_BTN_4_MASK 0x40 + +#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) + +/* No support for dynamically loadable drivers */ +#define DYN_DRV 0 + +/* The addresses of the static drivers */ +extern void supervision_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */ + /* End of supervision.h */ #endif - - diff --git a/include/target.h b/include/target.h new file mode 100644 index 000000000..af401ec35 --- /dev/null +++ b/include/target.h @@ -0,0 +1,73 @@ +/*****************************************************************************/ +/* */ +/* target.h */ +/* */ +/* Target specific definitions */ +/* */ +/* */ +/* */ +/* 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 _TARGET_H +#define _TARGET_H + + + +/* Include the correct target specific file */ +#if defined(__APPLE2ENH__) +# include <apple2enh.h> +#elif defined(__APPLE2__) +# include <apple2.h> +#elif defined(__ATARI__) +# include <atari.h> +#elif defined(__ATARI2600__) +# include <atari2600.h> +#elif defined(__ATARI5200__) +# include <atari5200.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__) +# include <geos.h> +#elif defined(__LYNX__) +# include <lynx.h> +#elif defined(__NES__) +# include <nes.h> +#elif defined(__OSIC1P__) +# include <osic1p.h> +#elif defined(__PCE__) +# include <pce.h> +#elif defined(__SUPERVISION__) +# include <supervision.h> +#elif defined(__TELESTRAT__) +# include <telestrat.h> +#endif + + + +/* End of target.h */ +#endif diff --git a/include/telestrat.h b/include/telestrat.h index 5a090647b..1865f19a0 100644 --- a/include/telestrat.h +++ b/include/telestrat.h @@ -30,6 +30,76 @@ + +/* Color defines */ +#define COLOR_BLACK 0x00 +#define COLOR_RED 0x01 +#define COLOR_GREEN 0x02 +#define COLOR_YELLOW 0x03 +#define COLOR_BLUE 0x04 +#define COLOR_MAGENTA 0x05 +#define COLOR_CYAN 0x06 +#define COLOR_WHITE 0x07 + +/* TGI color defines */ +/* White and red are swapped, so that the pallete +** driver is compatible with black-and-white drivers. +*/ +#define TGI_COLOR_BLACK COLOR_BLACK +#define TGI_COLOR_WHITE 1 +#define TGI_COLOR_GREEN COLOR_GREEN +#define TGI_COLOR_YELLOW COLOR_YELLOW +#define TGI_COLOR_BLUE COLOR_BLUE +#define TGI_COLOR_MAGENTA COLOR_MAGENTA +#define TGI_COLOR_CYAN COLOR_CYAN +#define TGI_COLOR_RED 7 + + +extern void telestrat_228_200_3_tgi[]; +extern void telestrat_240_200_2_tgi[]; /* Referred to by tgi_static_stddrv[] */ + +/* Define hardware */ +#include <_6522.h> +#define VIA (*(struct __6522*)0x300) + + + +/* These are defined to be FUNCT + NumberKey */ +#define CH_F1 0xB1 +#define CH_F2 0xB2 +#define CH_F3 0xB3 +#define CH_F4 0xB4 +#define CH_F5 0xB5 +#define CH_F6 0xB6 +#define CH_F7 0xB7 +#define CH_F8 0xB8 +#define CH_F9 0xB9 +#define CH_F10 0xB0 + + + +/* Character codes */ +#define CH_ULCORNER '+' +#define CH_URCORNER '+' +#define CH_LLCORNER '+' +#define CH_LRCORNER '+' +#define CH_TTEE '+' +#define CH_BTEE '+' +#define CH_LTEE '+' +#define CH_RTEE '+' +#define CH_CROSS '+' +#define CH_CURS_UP 11 +#define CH_CURS_DOWN 10 +#define CH_CURS_LEFT 8 +#define CH_CURS_RIGHT 9 +#define CH_DEL 127 +#define CH_ENTER 13 +#define CH_STOP 3 +#define CH_LIRA 95 +#define CH_ESC 27 + + + void oups(); void ping(); void zap(); diff --git a/include/tgi.h b/include/tgi.h index 02dff8868..f458180c5 100644 --- a/include/tgi.h +++ b/include/tgi.h @@ -38,9 +38,8 @@ -#ifndef _TGI_ERROR_H #include <tgi/tgi-error.h> -#endif +#include <target.h> @@ -284,6 +283,3 @@ int __fastcall__ tgi_imulround (int rhs, int lhs); /* End of tgi.h */ #endif - - - diff --git a/include/vic20.h b/include/vic20.h index c6ad9632d..44512b3fd 100644 --- a/include/vic20.h +++ b/include/vic20.h @@ -105,7 +105,8 @@ extern void vic20_ptvjoy_joy[]; extern void vic20_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */ - +extern void vic20_rama_emd[]; +extern void vic20_georam_emd[]; /* End of vic20.h */ #endif diff --git a/libsrc/Makefile b/libsrc/Makefile index 0583b6761..0d0cd320b 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -27,6 +27,7 @@ TARGETS = apple2 \ gamate \ lynx \ nes \ + none \ osic1p \ pce \ sim6502 \ diff --git a/libsrc/apple2/exehdr.s b/libsrc/apple2/exehdr.s index 778eee903..72ea390e9 100644 --- a/libsrc/apple2/exehdr.s +++ b/libsrc/apple2/exehdr.s @@ -1,16 +1,40 @@ ; ; Oliver Schmidt, 2012-06-10 ; -; This module supplies a 4 byte DOS 3.3 header -; containing the load address and load length. +; This module supplies an AppleSingle version 2 file header + entry with +; ID 11 according to https://tools.ietf.org/rfc/rfc1740.txt Appendix A. ; .export __EXEHDR__ : absolute = 1 ; Linker referenced + .import __FILETYPE__ ; Linker generated .import __MAIN_START__, __MAIN_LAST__ ; Linker generated +; ------------------------------------------------------------------------ + +; Data Fork +ID01_LENGTH = __MAIN_LAST__ - __MAIN_START__ +ID01_OFFSET = ID01 - START + +; ProDOS File Info +ID11_LENGTH = ID01 - ID11 +ID11_OFFSET = ID11 - START + ; ------------------------------------------------------------------------ .segment "EXEHDR" - .addr __MAIN_START__ ; Load address - .word __MAIN_LAST__ - __MAIN_START__ ; Load length +START: .byte $00, $05, $16, $00 ; Magic number + .byte $00, $02, $00, $00 ; Version number + .res 16 ; Filler + .byte 0, 2 ; Number of entries + .byte 0, 0, 0, 1 ; Entry ID 1 - Data Fork + .byte 0, 0, >ID01_OFFSET, <ID01_OFFSET ; Offset + .byte 0, 0, >ID01_LENGTH, <ID01_LENGTH ; Length + .byte 0, 0, 0, 11 ; Entry ID 11 - ProDOS File Info + .byte 0, 0, >ID11_OFFSET, <ID11_OFFSET ; Offset + .byte 0, 0, >ID11_LENGTH, <ID11_LENGTH ; Length +ID11: .byte 0, %11000011 ; Access - Destroy, Rename, Write, Read + .byte >__FILETYPE__, <__FILETYPE__ ; File Type + .byte 0, 0 ; Auxiliary Type high + .byte >__MAIN_START__, <__MAIN_START__ ; Auxiliary Type low +ID01: diff --git a/libsrc/apple2/joy/a2.stdjoy.s b/libsrc/apple2/joy/a2.stdjoy.s index ed2083255..7e90f7b98 100644 --- a/libsrc/apple2/joy/a2.stdjoy.s +++ b/libsrc/apple2/joy/a2.stdjoy.s @@ -52,7 +52,6 @@ PREAD := $FB1E ; Read paddle in X, return AD conv. value in Y .addr UNINSTALL .addr COUNT .addr READJOY - .addr 0 ; IRQ not used ; ------------------------------------------------------------------------ diff --git a/libsrc/apple2/tgi/a2.hi.s b/libsrc/apple2/tgi/a2.hi.s index 18f5724b5..e06b4a617 100644 --- a/libsrc/apple2/tgi/a2.hi.s +++ b/libsrc/apple2/tgi/a2.hi.s @@ -115,7 +115,6 @@ pages: .byte 2 ; Number of screens available .addr BAR .addr TEXTSTYLE .addr OUTTEXT - .addr 0 ; IRQ entry is unused ; ------------------------------------------------------------------------ diff --git a/libsrc/apple2/tgi/a2.lo.s b/libsrc/apple2/tgi/a2.lo.s index 045b0044f..7238463a9 100644 --- a/libsrc/apple2/tgi/a2.lo.s +++ b/libsrc/apple2/tgi/a2.lo.s @@ -85,7 +85,6 @@ Y2 := ptr4 .addr BAR .addr TEXTSTYLE .addr OUTTEXT - .addr 0 ; IRQ entry is unused ; ------------------------------------------------------------------------ diff --git a/libsrc/atari/cgetc.s b/libsrc/atari/cgetc.s index 2e9ebcb31..f8d938dfb 100644 --- a/libsrc/atari/cgetc.s +++ b/libsrc/atari/cgetc.s @@ -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 diff --git a/libsrc/atari/getdevice.s b/libsrc/atari/getdevice.s new file mode 100644 index 000000000..e0e700436 --- /dev/null +++ b/libsrc/atari/getdevice.s @@ -0,0 +1,78 @@ +; +; Oliver Schmidt, 2012-09-04 +; Christian Groessler, 2017-12-28 +; +; unsigned char getfirstdevice (void); +; unsigned char __fastcall__ getnextdevice (unsigned char device); +; + + .include "atari.inc" + .export _getfirstdevice + .export _getnextdevice + +MAX_DIO_DEVICES = 8 + +;------------------------------------------------------------------------------ +; _getfirstdevice + +_getfirstdevice: + lda #$FF + ; Fall through + +;------------------------------------------------------------------------------ +; _getnextdevice + +_getnextdevice: + tax +next: inx + cpx #MAX_DIO_DEVICES + beq none + + jsr check_device + bmi next + +done: txa + ldx #$00 + rts + +none: ldx #255 ; INVALID_DEVICE (see include/device.h) + bne done ; jump always + +;------------------------------------------------------------------------------ +; check_device - checks if a disk device is present +; input: X - device id (0 = D1, 1 = D2, ...) +; output: NF - 0/1 for detected/not detected +; X register preserved + +check_device: + txa + pha + lda #SIO_STAT + sta DCOMND ; set command into DCB + lda #%01000000 ; direction value, "receive data" + sta DSTATS ; set data flow directon + lda #15 + sta DTIMLO ; value got from DOS source + lda #4 + sta DAUX1 ; set sector # (dummy: 4) + sta DBYTLO ; # of bytes to transfer + lda #0 + sta DAUX2 + sta DBYTHI + lda #>DVSTAT + sta DBUFHI + lda #<DVSTAT + sta DBUFLO ; set buffer address into DCB + lda #DISKID ; SIO bus ID of diskette drive + sta DDEVIC + inx + stx DUNIT ; unit number (1-based) + + jsr SIOV ; execute SIO command + + pla + tax + lda DSTATS + rts + + .end diff --git a/libsrc/atari/joy/atrmj8.s b/libsrc/atari/joy/atrmj8.s index 0e8cd2a0a..9b02485d6 100644 --- a/libsrc/atari/joy/atrmj8.s +++ b/libsrc/atari/joy/atrmj8.s @@ -41,7 +41,6 @@ .addr UNINSTALL .addr COUNT .addr READJOY - .addr 0 ; IRQ entry not used ; ------------------------------------------------------------------------ ; Constants diff --git a/libsrc/atari/joy/atrstd.s b/libsrc/atari/joy/atrstd.s index 0c8799e21..0c49499f8 100644 --- a/libsrc/atari/joy/atrstd.s +++ b/libsrc/atari/joy/atrstd.s @@ -40,7 +40,6 @@ .addr UNINSTALL .addr COUNT .addr READJOY - .addr 0 ; IRQ entry not used ; ------------------------------------------------------------------------ ; Constants diff --git a/libsrc/atari/setcursor.s b/libsrc/atari/setcursor.s new file mode 100644 index 000000000..cf596d4fe --- /dev/null +++ b/libsrc/atari/setcursor.s @@ -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 diff --git a/libsrc/atari/tgi/atari_tgi_common.inc b/libsrc/atari/tgi/atari_tgi_common.inc index f4ef68165..cd486d91b 100644 --- a/libsrc/atari/tgi/atari_tgi_common.inc +++ b/libsrc/atari/tgi/atari_tgi_common.inc @@ -68,7 +68,6 @@ libref: .addr $0000 ; Library reference .addr BAR .addr TEXTSTYLE .addr OUTTEXT - .addr 0 ; IRQ entry is unused ; ****************************************************************************** diff --git a/libsrc/atari5200/conioscreen.s b/libsrc/atari5200/conioscreen.s index 2e86001c2..30c0e0788 100644 --- a/libsrc/atari5200/conioscreen.s +++ b/libsrc/atari5200/conioscreen.s @@ -58,7 +58,7 @@ clrscr: sta (SAVMSC),y rts - .segment "RODATA" + .segment "DLIST" ; display list for 20x24 text mode diff --git a/libsrc/atari5200/joy/atr5200std.s b/libsrc/atari5200/joy/atr5200std.s index 0b8b93b63..041dc6830 100644 --- a/libsrc/atari5200/joy/atr5200std.s +++ b/libsrc/atari5200/joy/atr5200std.s @@ -33,7 +33,6 @@ .addr UNINSTALL .addr COUNT .addr READJOY - .addr 0 ; IRQ entry not used .code diff --git a/libsrc/atmos/atmos.s b/libsrc/atmos/atmos.s index 6b5a4a49c..5822be8d9 100644 --- a/libsrc/atmos/atmos.s +++ b/libsrc/atmos/atmos.s @@ -7,9 +7,44 @@ .include "atmos.inc" -_atmos_ping := PING -_atmos_shoot := SHOOT -_atmos_explode := EXPLODE -_atmos_zap := ZAP -_atmos_tick := TICK -_atmos_tock := TOCK +.proc _atmos_ping + bit $31 + bvs L1 ; Atmos? + jmp PING +L1: jmp PING1 +.endproc + +.proc _atmos_shoot + bit $31 + bvs L1 ; Atmos? + jmp SHOOT +L1: jmp SHOOT1 +.endproc + +.proc _atmos_explode + bit $31 + bvs L1 ; Atmos? + jmp EXPLODE +L1: jmp EXPLODE1 +.endproc + +.proc _atmos_zap + bit $31 + bvs L1 ; Atmos? + jmp ZAP +L1: jmp ZAP1 +.endproc + +.proc _atmos_tick + bit $31 + bvs L1 ; Atmos? + jmp TICK +L1: jmp TICK1 +.endproc + +.proc _atmos_tock + bit $31 + bvs L1 ; Atmos? + jmp TOCK +L1: jmp TOCK1 +.endproc diff --git a/libsrc/atmos/cgetc.s b/libsrc/atmos/cgetc.s index f1d727a50..72cd9407a 100644 --- a/libsrc/atmos/cgetc.s +++ b/libsrc/atmos/cgetc.s @@ -6,7 +6,6 @@ ; .export _cgetc - .constructor initcgetc .import cursor .forceimport disable_caps @@ -53,14 +52,3 @@ @L3: rts .endproc - -; ------------------------------------------------------------------------ -; Switch the cursor off. Code goes into the ONCE segment, -; which will be reused after it is run. - -.segment "ONCE" - -initcgetc: - lsr STATUS - asl STATUS ; Clear bit zero - rts diff --git a/libsrc/atmos/cputc.s b/libsrc/atmos/cputc.s index a0ef14b70..f1ce5f2b7 100644 --- a/libsrc/atmos/cputc.s +++ b/libsrc/atmos/cputc.s @@ -8,6 +8,7 @@ .export _cputcxy, _cputc .export setscrptr, putchar + .constructor initcputc .import rvs .import popax .importzp ptr2 @@ -95,3 +96,13 @@ ScrTabHi: .byte >(SCREEN + Line * SCREEN_XSIZE) .endrep +; ------------------------------------------------------------------------ +; Switch the cursor off. Code goes into the ONCE segment, +; which will be reused after it is run. + +.segment "ONCE" + +initcputc: + lsr STATUS + asl STATUS ; Clear bit zero + rts diff --git a/libsrc/atmos/joy/atmos-ijk.s b/libsrc/atmos/joy/atmos-ijk.s new file mode 100644 index 000000000..6e75a3e0b --- /dev/null +++ b/libsrc/atmos/joy/atmos-ijk.s @@ -0,0 +1,134 @@ +; +; IJK joystick driver for the Atmos +; Can be used multiple times when statically linked to the application. +; +; 2002-12-20, Based on Ullrich von Bassewitz's code. +; 2017-11-01, Stefan Haubenthal +; + + .include "joy-kernel.inc" + .include "joy-error.inc" + .include "atmos.inc" + + .macpack module + + +; ------------------------------------------------------------------------ +; Header. Includes jump table + + module_header _atmos_ijk_joy + +; Driver signature + + .byte $6A, $6F, $79 ; "joy" + .byte JOY_API_VERSION ; Driver API version number + +; Library reference + + .addr $0000 + +; Jump table. + + .addr INSTALL + .addr UNINSTALL + .addr COUNT + .addr READ + +; ------------------------------------------------------------------------ +; Constants + +JOY_COUNT = 2 ; Number of joysticks we support + +.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 JOY_ERR_xx code in a/x. +; + +INSTALL: + lda #%11000000 + sta VIA::DDRA + sta VIA::PRA + lda VIA::PRA + and #%00100000 + bne ijkPresent + lda #<JOY_ERR_NO_DEVICE + .byte $2C ; Skip next opcode +ijkPresent: + lda #<JOY_ERR_OK + ldx #>JOY_ERR_OK +; 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 + + +; ------------------------------------------------------------------------ +; COUNT: Return the total number of available joysticks in a/x. +; + +COUNT: + lda #<JOY_COUNT + ldx #>JOY_COUNT + rts + +; ------------------------------------------------------------------------ +; READ: Read a particular joystick passed in A. +; + +READ: + bne right + + ; Ensure Printer Strobe is set to Output + lda #%10110111 + sta VIA::DDRB + ; Set Strobe Low + lda #%00000000 + sta VIA::PRB + ; Set Top two bits of PortA to Output and rest as Input + lda #%11000000 + sta VIA::DDRA + + ; Select Left Joystick + lda #%01111111 + sta VIA::PRA + ; Read back Left Joystick state + lda VIA::PRA + ; Mask out unused bits + and #%00011111 + ; Invert Bits + eor #%00011111 + ; Index table to conform to Generic Format + tax + lda GenericIJKBits,X + bne L1 + +right: + ; Select Right Joystick + lda #%10111111 + sta VIA::PRA + ; Read back Right Joystick state and rejig bits + lda VIA::PRA + and #%00011111 + eor #%00011111 + tax + lda GenericIJKBits,X + + ; Restore VIA PortA state +L1: ldx #%11111111 + stx VIA::DDRA + inx ; x=0 + rts + +.rodata +GenericIJKBits: + .byte 0,2,1,3,32,34,33,0,8,10,9,0,40,42,41,0 + .byte 16,18,17,0,48,50,49,0,0,0,0,0,0,0,0,0 diff --git a/libsrc/atmos/joy/atmos-pase.s b/libsrc/atmos/joy/atmos-pase.s index 637571c04..fd64901c9 100644 --- a/libsrc/atmos/joy/atmos-pase.s +++ b/libsrc/atmos/joy/atmos-pase.s @@ -34,7 +34,6 @@ .addr UNINSTALL .addr COUNT .addr READ - .addr 0 ; IRQ entry unused ; ------------------------------------------------------------------------ ; Constants diff --git a/libsrc/atmos/tgi/atmos-228-200-3.s b/libsrc/atmos/tgi/atmos-228-200-3.s index ae9b0f775..98d2cef96 100644 --- a/libsrc/atmos/tgi/atmos-228-200-3.s +++ b/libsrc/atmos/tgi/atmos-228-200-3.s @@ -59,7 +59,6 @@ YSIZE = 8 ; System font height .addr BAR .addr TEXTSTYLE .addr OUTTEXT - .addr 0 ; IRQ entry is unused ; ------------------------------------------------------------------------ ; Data. diff --git a/libsrc/atmos/tgi/atmos-240-200-2.s b/libsrc/atmos/tgi/atmos-240-200-2.s index 943ec5389..2643e08fd 100644 --- a/libsrc/atmos/tgi/atmos-240-200-2.s +++ b/libsrc/atmos/tgi/atmos-240-200-2.s @@ -59,7 +59,6 @@ YSIZE = 8 ; System font height .addr BAR .addr TEXTSTYLE .addr OUTTEXT - .addr 0 ; IRQ entry is unused ; ------------------------------------------------------------------------ ; Data. diff --git a/libsrc/atmos/tgi_colors.s b/libsrc/atmos/tgi_colors.s deleted file mode 100644 index 6ef3729b4..000000000 --- a/libsrc/atmos/tgi_colors.s +++ /dev/null @@ -1,8 +0,0 @@ -; -; Target-specific black & white values for use by the target-shared TGI kernel -; - - .include "tgi-kernel.inc" - - .export tgi_color_black:zp = $00 - .export tgi_color_white:zp = $01 diff --git a/libsrc/atmos/toascii.s b/libsrc/atmos/toascii.s deleted file mode 100644 index 77f050021..000000000 --- a/libsrc/atmos/toascii.s +++ /dev/null @@ -1,14 +0,0 @@ -; -; char __fastcall__ toascii (char c); -; /* Convert a target-specific character to ASCII. */ -; - -.export _toascii - -.proc _toascii - -; .X must be zero, on return. - ldx #>$0000 - rts - -.endproc diff --git a/libsrc/c128/acc_c128_speed.s b/libsrc/c128/acc_c128_speed.s new file mode 100644 index 000000000..7994a52ae --- /dev/null +++ b/libsrc/c128/acc_c128_speed.s @@ -0,0 +1,51 @@ +; +; 2018-04-23, Marco van den Heuvel +; 2018-04-26, Greg King +; + +; unsigned char __fastcall__ set_c128_speed (unsigned char speed); +; +;/* Set the speed of the C128 8502 CPU; using SPEED_SLOW will switch to +; * 1 Mhz (slow) mode, SPEED_2X or SPEED_FAST will switch to 2Mhz (fast) mode. +; * +; * Note that any value higher or equal to SPEED_2X will switch to fast mode. +; * +; * This function will return the actual speed the CPU is at, after trying +; * to set the requested speed; to my knowledge, the switching should not fail. +; * +; * For C64 programs, a check for a C128 in C64 mode is needed; make sure you +; * use 'detect_c128();' before using. +; * +; * For C128 programs, no detect function call is needed. +; */ + +; unsigned char get_c128_speed (void); +; +;/* Get the speed of the C128 8502 CPU. +; * +; * Possible return values: +; * SPEED_SLOW : Slow mode +; * SPEED_2X : Fast mode +; * +; * For C64 programs, a check for a C128 in C64 mode is needed; make sure you +; * use 'detect_c128();' before using. +; * +; * For C128 programs, no detect function call is needed. +; */ + + .export _set_c128_speed + .export _get_c128_speed + + .include "accelerator.inc" + +_set_c128_speed: + cmp #SPEED_2X + lda #$00 ; clear VIC-IIe test bit + rol a ; carry flag is speed bit + sta C128_VICIIE_CLK + +_get_c128_speed: + lda C128_VICIIE_CLK + and #$01 + ldx #>$0000 + rts diff --git a/libsrc/c128/acc_detect_c128.s b/libsrc/c128/acc_detect_c128.s new file mode 100644 index 000000000..f40fe395a --- /dev/null +++ b/libsrc/c128/acc_detect_c128.s @@ -0,0 +1,24 @@ +; +; Marco van den Heuvel, 2018-04-23 +; + +; unsigned char detect_c128 (void); +; +;/* Check if the C128 8502 CPU is the current CPU. +; * +; * Possible return values: +; * 0x00 : C128 8502 is not the current CPU +; * 0x01 : C128 8502 is the current CPU +; */ + + .export _detect_c128 + + .include "accelerator.inc" + +_detect_c128: + ldx #$00 + lda #$01 + +; Make sure the CPU is a 8502 + .byte $3A ; NOP on 8502, DEA on 65(S)C(E)02, 4510 and 65816 + rts diff --git a/libsrc/c128/acc_detect_scpu.s b/libsrc/c128/acc_detect_scpu.s new file mode 100644 index 000000000..e42d90548 --- /dev/null +++ b/libsrc/c128/acc_detect_scpu.s @@ -0,0 +1,34 @@ +; +; Marco van den Heuvel, 2018-04-08 +; + +; unsigned char detect_scpu (void); +; +;/* Check for the presence of the SuperCPU cartridge. +; * +; * Possible return values: +; * 0x00 : SuperCPU cartridge not present +; * 0x01 : SuperCPU cartridge present +; */ + + .export _detect_scpu + + .include "accelerator.inc" +_detect_scpu: + ldx #$00 + txa + +; Make sure the current CPU is a 65816 + clc + .byte $E2,$01 ; NOP #$01 on 6510 and 65(S)C02, LDA $(01,S),Y on 65CE02 and 4510, SEP #$01 on 65816 + bcc not_found ; carry will be set on 65816 + +; 65816 has been detected, make sure it's the SuperCPU cartridge + + lda SuperCPU_Detect + asl + bcs not_found +found: + lda #$01 +not_found: + rts diff --git a/libsrc/c128/acc_scpu_speed.s b/libsrc/c128/acc_scpu_speed.s new file mode 100644 index 000000000..9f932aecd --- /dev/null +++ b/libsrc/c128/acc_scpu_speed.s @@ -0,0 +1,59 @@ +; +; Marco van den Heuvel, 2018-04-09 +; + +; unsigned char __fastcall__ set_scpu_speed (unsigned char speed); +; +;/* Set the speed of the SuperCPU cartridge, using SPEED_SLOW will switch to +; * 1 Mhz mode, SPEED_20X or SPEED_FAST will switch to 20 Mhz mode. +; * +; * Note that any value lower than SPEED_20X will switch to 1 Mhz mode, and +; * any value higher or equal to SPEED_20X will switch to 20 Mhz mode. +; * +; * This function will return the actual speed the CPU is at after trying +; * to set the requested speed, if this is not the speed that was requested +; * then possibly the hardware speed switch prevented any software speed +; * switching. +; * +; * This function does not check for the presence of the SuperCPU cartridge, +; * make sure you use 'detect_scpu();' before using. +; */ + +; unsigned char get_scpu_speed (void); +; +;/* Get the speed of the SuperCPU cartridge. +; * +; * Possible return values: +; * SPEED_1X : 1 Mhz mode +; * SPEED_20X : 20 Mhz mode +; * +; * This function does not check for the presence of the SuperCPU cartridge, +; * make sure you use 'detect_scpu();' before using. +; */ + + .export _set_scpu_speed + .export _get_scpu_speed + + .include "accelerator.inc" + +_set_scpu_speed: + cmp #SPEED_20X + bcs high_speed +low_speed: + sta SuperCPU_Slow + jmp _get_scpu_speed + +high_speed: + sta SuperCPU_Fast + +_get_scpu_speed: + ldx #$00 + lda SuperCPU_Speed_Mode + asl + asl + bcc is_fast_speed + lda #SPEED_1X + rts +is_fast_speed: + lda #SPEED_20X + rts diff --git a/libsrc/c128/cpeekc.s b/libsrc/c128/cpeekc.s new file mode 100644 index 000000000..9d64388a4 --- /dev/null +++ b/libsrc/c128/cpeekc.s @@ -0,0 +1,70 @@ +; +; 2016-02-28, Groepaz +; 2017-06-26, Greg King +; +; char cpeekc (void); +; + + .export _cpeekc + + .import plot, popa + + .include "zeropage.inc" + .include "c128.inc" + + +_cpeekc: + lda MODE + bmi @c80 + + ldy CURS_X + lda (SCREEN_PTR),y ; get char + +@return: + and #<~$80 ; remove reverse flag + +; Convert the screen code into a PetSCII code. +; $00 - $1F: +$40 +; $20 - $3F +; $40 - $5f: +$20 +; $60 - $7F: +$40 + + cmp #$20 + bcs @sk1 ;(bge) + ora #$40 + rts + +@sk1: cmp #$40 + bcc @end ;(blt) + cmp #$60 + bcc @sk2 ;(blt) + ;sec + adc #$20 - $01 +@sk2: ;clc ; both above cmp and adc clear carry flag + adc #$20 +@end: rts + +@c80: + lda SCREEN_PTR + ldy SCREEN_PTR+1 + clc + adc CURS_X + bcc @s + iny + + ; get byte from VDC mem +@s: ldx #VDC_DATA_LO + stx VDC_INDEX +@L0: bit VDC_INDEX + bpl @L0 + sta VDC_DATA + dex + stx VDC_INDEX + sty VDC_DATA + + ldx #VDC_RAM_RW + stx VDC_INDEX +@L1: bit VDC_INDEX + bpl @L1 ; wait for blanking + lda VDC_DATA + jmp @return diff --git a/libsrc/c128/cpeekcolor.s b/libsrc/c128/cpeekcolor.s new file mode 100644 index 000000000..9a8c3bfdc --- /dev/null +++ b/libsrc/c128/cpeekcolor.s @@ -0,0 +1,56 @@ +; +; 2016-02-28, Groepaz +; 2017-06-26, Greg King +; +; unsigned char cpeekcolor (void); +; + + .export _cpeekcolor + + .include "c128.inc" + + +_cpeekcolor: + bit MODE + bmi @c80 + + ldy CURS_X + lda (CRAM_PTR),y ; get color + and #$0F + ldx #>$0000 + rts + +@c80: lda CRAM_PTR + ldy CRAM_PTR+1 + clc + adc CURS_X + bcc @s + iny + + ; get byte from VDC mem +@s: ldx #VDC_DATA_LO + stx VDC_INDEX +@L0: bit VDC_INDEX + bpl @L0 + sta VDC_DATA + dex + stx VDC_INDEX + sty VDC_DATA + + ldx #VDC_RAM_RW + stx VDC_INDEX +@L1: bit VDC_INDEX + bpl @L1 ; wait for blanking + lda VDC_DATA + and #$0F + +; translate VDC->VIC colour + +vdctovic: + ldy #$0F + 1 +@L2: dey + cmp $CE5C,y + bne @L2 + tya + ldx #>$0000 + rts diff --git a/libsrc/c128/cpeekrevers.s b/libsrc/c128/cpeekrevers.s new file mode 100644 index 000000000..c36e4ac44 --- /dev/null +++ b/libsrc/c128/cpeekrevers.s @@ -0,0 +1,51 @@ +; +; 2016-02-28, Groepaz +; 2017-06-26, Greg King +; +; unsigned char cpeekrevers (void); +; + + .export _cpeekrevers + + .include "zeropage.inc" + .include "c128.inc" + + +_cpeekrevers: + lda MODE + bmi @c80 + + ldy CURS_X + lda (SCREEN_PTR),y ; get char + +@return: + and #$80 ; get reverse flag + asl a + tax ; ldx #>$0000 + rol a ; return boolean value + rts + +@c80: + lda SCREEN_PTR + ldy SCREEN_PTR+1 + clc + adc CURS_X + bcc @s + iny + + ; get byte from VDC mem +@s: ldx #VDC_DATA_LO + stx VDC_INDEX +@L0: bit VDC_INDEX + bpl @L0 + sta VDC_DATA + dex + stx VDC_INDEX + sty VDC_DATA + + ldx #VDC_RAM_RW + stx VDC_INDEX +@L1: bit VDC_INDEX + bpl @L1 ; wait for blanking + lda VDC_DATA + jmp @return diff --git a/libsrc/c128/cpeeks.s b/libsrc/c128/cpeeks.s new file mode 100644 index 000000000..12c3349e4 --- /dev/null +++ b/libsrc/c128/cpeeks.s @@ -0,0 +1,159 @@ +; +; 2017-07-05, Greg King +; 2017-12-12, Groepaz +; +; void cpeeks (char* s, unsigned length); +; + + .export _cpeeks + + .import popax + .importzp ptr1, ptr2, ptr3, tmp1, tmp2 + + .macpack generic + +; FIXME c128 needs special version that handles the 80-column VDC. + + .include "c128.inc" + +_cpeeks: + eor #<$FFFF ; counting a word upward is faster + sta ptr3 ; so, we use -(length + 1) + txa + eor #>$FFFF + sta ptr3+1 + + lda MODE + bmi c80 + + lda SCREEN_PTR + ldx SCREEN_PTR+1 + sta ptr2 + stx ptr2+1 + ldy CURS_X + sty tmp2 + + jsr popax + sta tmp1 ; (will be a .Y index) + stx ptr1+1 + ldx #<$0000 + stx ptr1 + bze L3 ; branch always + +L4: ldy tmp2 + lda (ptr2),y ; get char + iny + bnz L2 + inc ptr2+1 +L2: sty tmp2 + and #<~$80 ; remove reverse bit + +; Convert the screen code into a PetSCII code. +; $00 - $1F: +$40 +; $20 - $3F +; $40 - $5f: +$20 +; $60 - $7F: +$40 + + cmp #$20 + blt @sk1 ;(bcc) + cmp #$40 + blt L5 + cmp #$60 + blt @sk2 ;(bcc) + clc +@sk1: adc #$20 +@sk2: ;clc ; both above cmp and adc clear carry flag + adc #$20 + +L5: ldy tmp1 + sta (ptr1),y + iny + bnz L1 + inc ptr1+1 +L1: sty tmp1 + +L3: inc ptr3 ; count length + bnz L4 + inc ptr3+1 + bnz L4 + + txa ; terminate the string + ldy tmp1 + sta (ptr1),y + rts + + ;----------------------------------------------------------- +c80: + lda SCREEN_PTR + clc + adc CURS_X + sta ptr2 + lda SCREEN_PTR+1 + adc #0 + sta ptr2+1 + + jsr popax + sta tmp1 ; (will be a .Y index) + stx ptr1+1 + ldx #<$0000 + stx ptr1 + bze L3a ; branch always + +L4a: + lda ptr2 + ldy ptr2+1 + inc ptr2 + bne @s + inc ptr2+1 +@s: + ; get byte from VDC mem + ldx #VDC_DATA_LO + stx VDC_INDEX +@L0: bit VDC_INDEX + bpl @L0 + sta VDC_DATA + dex + stx VDC_INDEX + sty VDC_DATA + + ldx #VDC_RAM_RW + stx VDC_INDEX +@L1: bit VDC_INDEX + bpl @L1 ; wait for blanking + lda VDC_DATA + + and #<~$80 ; remove reverse bit + +; Convert the screen code into a PetSCII code. +; $00 - $1F: +$40 +; $20 - $3F +; $40 - $5f: +$20 +; $60 - $7F: +$40 + + cmp #$20 + blt @sk1 ;(bcc) + cmp #$40 + blt L5a + cmp #$60 + blt @sk2 ;(bcc) + clc +@sk1: adc #$20 +@sk2: ;clc ; both above cmp and adc clear carry flag + adc #$20 + +L5a: ldy tmp1 + sta (ptr1),y + iny + bnz L1a + inc ptr1+1 +L1a: sty tmp1 + +L3a: inc ptr3 ; count length + bnz L4a + inc ptr3+1 + bnz L4a + + lda #0 ; terminate the string + ldy tmp1 + sta (ptr1),y + rts diff --git a/libsrc/c128/emd/c128-reu.s b/libsrc/c128/emd/c128-reu.s index a858c591e..3ded00d67 100644 --- a/libsrc/c128/emd/c128-reu.s +++ b/libsrc/c128/emd/c128-reu.s @@ -55,6 +55,8 @@ REU_TRIGGER = $FF00 ; REU command trigger OP_COPYFROM = $ED OP_COPYTO = $EC +OP_COPYFROM_ALOAD = $B1 +OP_COPYTO_ALOAD = $B0 ; ------------------------------------------------------------------------ ; Data. @@ -92,17 +94,56 @@ INSTALL: cmp REU_REUADDR ; Check for presence of REU bne nodevice - ldy #>(128*4) ; Assume 128KB - lda REU_STATUS - and #$10 ; Check size bit - beq @L1 - ldy #>(256*4) ; 256KB when size bit is set -@L1: sty pagecount+1 - +; determine the size + php + sei ldy #$FF - sty curpage - sty curpage+1 ; Invalidate the current page - txa ; X = A = EM_ERR_OK +loop: + sty window + jsr reu_size_check_common + ldx #OP_COPYTO_ALOAD + stx REU_COMMAND + dey + cpy #$FF + bne loop + iny +size_loop: + jsr reu_size_check_common + ldx #OP_COPYFROM_ALOAD + stx REU_COMMAND + cpy window + bne size_found + iny + bne size_loop +size_found: + plp + ldx #$00 + cpy #$00 ; too many pages, shave off 2 + bne pagecount_ok + dex + dex + dey +pagecount_ok: + stx pagecount + sty pagecount+1 + lda #<EM_ERR_OK + ldx #>EM_ERR_OK + rts + +; common REU setup for size check +reu_size_check_common: + sty REU_REUADDR+2 + ldx #<window + stx REU_C64ADDR + ldx #>window + stx REU_C64ADDR+1 + ldx #$00 + stx REU_REUADDR + stx REU_REUADDR+1 + stx REU_COUNT+1 + stx REU_CONTROL + inx + stx REU_COUNT rts ; No REU found diff --git a/libsrc/c128/isfast.s b/libsrc/c128/isfast.s new file mode 100644 index 000000000..d40e2c7e9 --- /dev/null +++ b/libsrc/c128/isfast.s @@ -0,0 +1,21 @@ +; +; Marco van den Heuvel, 2018-03-19 +; +; unsigned char isfast (void); +; /* Returns 1 if the CPU is in 2MHz mode. */ +; + + .export _isfast + + .include "c128.inc" + + +.proc _isfast + + lda VIC_CLK_128 + and #$01 + ldx #$00 + rts + +.endproc + diff --git a/libsrc/c128/joy/c128-ptvjoy.s b/libsrc/c128/joy/c128-ptvjoy.s index c9ae39a47..180f7667d 100644 --- a/libsrc/c128/joy/c128-ptvjoy.s +++ b/libsrc/c128/joy/c128-ptvjoy.s @@ -36,7 +36,6 @@ .addr UNINSTALL .addr COUNT .addr READ - .addr 0 ; IRQ entry unused ; ------------------------------------------------------------------------ ; Constants diff --git a/libsrc/c128/joy/c128-stdjoy.s b/libsrc/c128/joy/c128-stdjoy.s index 943361da5..bf2e2fea7 100644 --- a/libsrc/c128/joy/c128-stdjoy.s +++ b/libsrc/c128/joy/c128-stdjoy.s @@ -36,7 +36,6 @@ .addr UNINSTALL .addr COUNT .addr READ - .addr 0 ; IRQ entry not used ; ------------------------------------------------------------------------ ; Constants diff --git a/libsrc/c128/tgi/c128-vdc.s b/libsrc/c128/tgi/c128-vdc.s index 5100f7f7d..f48b530f6 100644 --- a/libsrc/c128/tgi/c128-vdc.s +++ b/libsrc/c128/tgi/c128-vdc.s @@ -88,7 +88,6 @@ pages: .byte 1 ; Number of screens available .addr BAR .addr TEXTSTYLE .addr OUTTEXT - .addr 0 ; IRQ entry is unused ; ------------------------------------------------------------------------ ; Data. diff --git a/libsrc/c128/tgi/c128-vdc2.s b/libsrc/c128/tgi/c128-vdc2.s index a7238e877..4b7b17c57 100644 --- a/libsrc/c128/tgi/c128-vdc2.s +++ b/libsrc/c128/tgi/c128-vdc2.s @@ -89,7 +89,6 @@ pages: .byte 0 ; Number of screens available .addr BAR .addr TEXTSTYLE .addr OUTTEXT - .addr 0 ; IRQ entry is unused ; ------------------------------------------------------------------------ ; Data. diff --git a/libsrc/c128/tgi_colors.s b/libsrc/c128/tgi_colors.s deleted file mode 100644 index 6ef3729b4..000000000 --- a/libsrc/c128/tgi_colors.s +++ /dev/null @@ -1,8 +0,0 @@ -; -; Target-specific black & white values for use by the target-shared TGI kernel -; - - .include "tgi-kernel.inc" - - .export tgi_color_black:zp = $00 - .export tgi_color_white:zp = $01 diff --git a/libsrc/c16/fast.s b/libsrc/c16/fast.s new file mode 100644 index 000000000..e48813969 --- /dev/null +++ b/libsrc/c16/fast.s @@ -0,0 +1,22 @@ +; +; Marco van den Heuvel, 2018-03-20 +; +; void fast (void); +; /* Switch the CPU into double clock mode. */ +; + + .export _fast + + .include "plus4.inc" + + +.proc _fast + + lda TED_CLK + and #%11111101 + sta TED_CLK + rts + +.endproc + + diff --git a/libsrc/c16/isfast.s b/libsrc/c16/isfast.s new file mode 100644 index 000000000..ff104d97f --- /dev/null +++ b/libsrc/c16/isfast.s @@ -0,0 +1,22 @@ +; +; Marco van den Heuvel, 2018-03-20 +; +; unsigned char isfast (void); +; /* Returns 1 if the CPU is in double clock mode. */ +; + + .export _isfast + + .include "plus4.inc" + + +.proc _isfast + + lda TED_CLK + lsr + and #$01 + ldx #$00 + rts + +.endproc + diff --git a/libsrc/c16/slow.s b/libsrc/c16/slow.s new file mode 100644 index 000000000..18b8c231c --- /dev/null +++ b/libsrc/c16/slow.s @@ -0,0 +1,22 @@ +; +; Marco van den Heuvel, 2018-03-28 +; +; void slow (void); +; /* Switch the CPU into single clock mode. */ +; + + .export _slow + + .include "plus4.inc" + + +.proc _slow + + lda TED_CLK + ora #%00000010 + sta TED_CLK + rts + +.endproc + + diff --git a/libsrc/c64/acc_c128_speed.s b/libsrc/c64/acc_c128_speed.s new file mode 100644 index 000000000..678f52d0c --- /dev/null +++ b/libsrc/c64/acc_c128_speed.s @@ -0,0 +1,5 @@ +; +; Marco van den Heuvel, 2018-04-23 +; + +.include "../c128/acc_c128_speed.s" diff --git a/libsrc/c64/acc_c64dtv_speed.s b/libsrc/c64/acc_c64dtv_speed.s new file mode 100644 index 000000000..d6cf8b994 --- /dev/null +++ b/libsrc/c64/acc_c64dtv_speed.s @@ -0,0 +1,64 @@ +; +; Marco van den Heuvel, 2018-04-14 +; + +; unsigned char __fastcall__ set_c64dtv_speed (unsigned char speed); +; +;/* Set the speed of the C64DTV, using SPEED_SLOW will switch to +; * slow mode, SPEED_2X or SPEED_FAST will switch to fast mode. +; * +; * Note that any value higher or equal to SPEED_2X will switch to fast mode. +; * +; * This function will return the actual speed the CPU is at after trying +; * to set the requested speed, to my knowledge the switching should not fail. +; * +; * This function does not check for the presence of the C64DTV, +; * make sure you use 'detect_c64dtv();' before using. +; */ + +; unsigned char get_c64dtv_speed (void); +; +;/* Get the speed of the C64DTV. +; * +; * Possible return values: +; * SPEED_1X : slow mode +; * SPEED_2X : fast mode +; * +; * This function does not check for the presence of the C64DTV, +; * make sure you use 'detect_c64dtv();' before using. +; */ + + .export _set_c64dtv_speed + .export _get_c64dtv_speed + + .include "accelerator.inc" + +_set_c64dtv_speed: + cmp #SPEED_2X + bcs high_speed +low_speed: + ldx #C64DTV_Slow +set_speed: + .byte $32,$99 ; SAC #$99 set accumulator to reg 9 (cpu control) + txa ; (re)set skip and burst bits + .byte $32,$00 ; SAC #$00 set accumulator back to reg 0 + jmp _get_c64dtv_speed + +high_speed: + ldx #C64DTV_Fast + bne set_speed + + +_get_c64dtv_speed: + .byte $32,$99 ; SAC #$99 set accumulator to reg 9 (cpu control) + tax + .byte $32,$00 ; SAC #$00 set accumulator back to reg 0 + txa + and #C64DTV_Fast + bne in_fast_mode + lda #$00 + .byte $2C +in_fast_mode: + lda #$01 + ldx #$00 + rts diff --git a/libsrc/c64/acc_c65_speed.s b/libsrc/c64/acc_c65_speed.s new file mode 100755 index 000000000..92f2bac06 --- /dev/null +++ b/libsrc/c64/acc_c65_speed.s @@ -0,0 +1,69 @@ +; +; Marco van den Heuvel, 2018-04-27 +; + +; unsigned char __fastcall__ set_c65_speed (unsigned char speed); +; +;/* Set the speed of the C65 CPU, using SPEED_SLOW will switch to +; * 1 Mhz mode, SPEED_3X or SPEED_FAST will switch to 3.5 Mhz (fast) mode. +; * +; * Note that any value higher or equal to SPEED_3X will switch to fast mode. +; * +; * This function will return the actual speed the CPU is at after trying +; * to set the requested speed, to my knowledge the switching should not fail. +; * +; * This function does not check for the presence of a C65/C64DX in C64 mode, +; * make sure you use 'detect_c65();' before using. +; */ + +; unsigned char get_c65_speed (void); +; +;/* Get the speed of the C65 CPU. +; * +; * Possible return values: +; * SPEED_SLOW : 1 Mhz mode +; * SPEED_3X : 3.5 Mhz mode +; * +; * This function does not check for the presence of a C65/C64DX in C64 mode, +; * make sure you use 'detect_c65();' before using. +; */ + + .export _set_c65_speed + .export _get_c65_speed + + .include "accelerator.inc" + +_set_c65_speed: + tay + jsr activate_new_vic_mode + cpy #SPEED_3X + bcs high_speed +low_speed: + and #$BF +store_speed: + sta C65_VICIII_CTRL_B + lda C65_VICIII_CTRL_B + jmp return_c65_speed + +high_speed: + ora #$40 + bne store_speed + +_get_c65_speed: + jsr activate_new_vic_mode +return_c65_speed: + sta C65_VICIII_KEY + and #$40 + beq speed_is_slow ; when this branch is taken then register A is already set to SPEED_SLOW + lda #SPEED_3X +speed_is_slow: + ldx #$00 + rts + +activate_new_vic_mode: + lda #C65_VICIII_UNLOCK_1 + sta C65_VICIII_KEY + lda #C65_VICIII_UNLOCK_2 + sta C65_VICIII_KEY + lda C65_VICIII_CTRL_B + rts diff --git a/libsrc/c64/acc_chameleon_speed.s b/libsrc/c64/acc_chameleon_speed.s new file mode 100755 index 000000000..ce51b9dde --- /dev/null +++ b/libsrc/c64/acc_chameleon_speed.s @@ -0,0 +1,100 @@ +; +; Marco van den Heuvel, 2018-04-25 +; + +; unsigned char __fastcall__ set_chameleon_speed (unsigned char speed); +; +;/* Set the speed of the Chameleon cartridge, the following inputs +; * are accepted: +; * SPEED_SLOW : 1 Mhz mode +; * SPEED_1X : 1 Mhz mode +; * SPEED_2X : 2 Mhz mode +; * SPEED_3X : 3 Mhz mode +; * SPEED_4X : 4 Mhz mode +; * SPEED_5X : 5 Mhz mode +; * SPEED_6X : 6 Mhz mode +; * SPEED_FAST : Maximum speed mode +; * +; * Note that any value higher or equal to SPEED_7X will switch to maximum +; * speed mode. +; * +; * This function will return the actual speed the CPU is at after trying +; * to set the requested speed, to my knowledge the switching should not fail. +; * +; * This function does not check for the presence of the Chameleon cartridge, +; * make sure you use 'detect_chameleon();' before using. +; */ + +; unsigned char get_chameleon_speed (void); +; +;/* Get the speed of the Chameleon cartridge. +; * +; * Possible return values: +; * SPEED_SLOW : Slow mode +; * SPEED_2X : 2Mhz mode +; * SPEED_3X : 3Mhz mode +; * SPEED_4X : 4Mhz mode +; * SPEED_5X : 5Mhz mode +; * SPEED_6X : 6Mhz mode +; * SPEED_FAST : Maximum speed mode +; * +; * This function does not check for the presence of the Chameleon cartridge, +; * make sure you use 'detect_chameleon();' before using. +; */ + + .export _set_chameleon_speed + .export _get_chameleon_speed + + .include "accelerator.inc" + +_set_chameleon_speed: + cmp #SPEED_7X + bcs maximum_speed + cmp #SPEED_1X + beq low_speed + ora #$80 +set_speed: + jsr activate_regs + sta CHAMELEON_CFGTUR + jmp return_speed + +low_speed: + lda #CHAMELEON_CFGTUR_LIMIT_1MHZ + bne set_speed + +maximum_speed: + lda #CHAMELEON_CFGTUR_LIMIT_NONE + bne set_speed + +_get_chameleon_speed: + jsr activate_regs +return_speed: + ldx #$00 + lda CHAMELEON_CFGTUR + tay + and #%10000000 + beq return_value + tya + and #%00001000 + bne is_slow_mode + tya + and #%00000111 + beq is_max_mode +return_value: + ldy #CHAMELEON_DISABLE_REGS + sty CHAMELEON_CFGENA + rts + +is_slow_mode: + txa + bne return_value + +is_max_mode: + lda #SPEED_FAST + bne return_value + +activate_regs: + ldy #CHAMELEON_ENABLE_REGS + sty CHAMELEON_CFGENA + rts + diff --git a/libsrc/c64/acc_detect_c128.s b/libsrc/c64/acc_detect_c128.s new file mode 100644 index 000000000..12817001a --- /dev/null +++ b/libsrc/c64/acc_detect_c128.s @@ -0,0 +1,33 @@ +; +; 2018-04-20, Marco van den Heuvel +; 2018-04-26, Greg King +; + +; unsigned char detect_c128 (void); +; +;/* Check for the presence of a C128 in C64 mode. +; * +; * Possible return values: +; * 0x00 : C128 in C64 mode not present +; * 0x01 : C128 in C64 mode present +; */ + + .export _detect_c128 + + .include "accelerator.inc" + +_detect_c128: + ldx #>$0001 + lda #<$0001 + +; Make sure the CPU is an 8502. + .byte $3A ; NOP on 8502, DEA on 65(S)C(E)02, 4510, and 65816 + beq detect_end + +; Make sure a C128 VIC-IIe is present. + ldy C128_VICIIE_CLK + cpy #$FF + bne detect_end + txa ; return zero when not VIC-IIe +detect_end: + rts diff --git a/libsrc/c64/acc_detect_c64dtv.s b/libsrc/c64/acc_detect_c64dtv.s new file mode 100644 index 000000000..1734095b1 --- /dev/null +++ b/libsrc/c64/acc_detect_c64dtv.s @@ -0,0 +1,44 @@ +; +; Marco van den Heuvel, 2018-04-14 +; + +; unsigned char detect_c64dtv (void); +; +;/* Check for the presence of the C64DTV. +; * +; * Possible return values: +; * 0x00 : C64DTV not present +; * 0x01 : C64DTV present +; */ + + .export _detect_c64dtv + + .include "accelerator.inc" + +_detect_c64dtv: + ldy C64DTV_Extended_Regs + lda #$00 + ldx $D000 + +; Make sure the CPU is a 6510 + .byte $1A ; NOP on 8502, INA on 65(S)C(E)02, 4510 and 65816 + bne not_found + lda #$01 + sta C64DTV_Extended_Regs + +; Check if $D000 is mirrored at $D040 + cpx $D040 + bne found + inc $D000 + cpx $D040 + bne not_found +found: + lda #$01 + .byte $2C +not_found: + lda #$00 + stx $D000 + ldx #$00 + sty C64DTV_Extended_Regs + rts + diff --git a/libsrc/c64/acc_detect_c65.s b/libsrc/c64/acc_detect_c65.s new file mode 100755 index 000000000..6d8af3c01 --- /dev/null +++ b/libsrc/c64/acc_detect_c65.s @@ -0,0 +1,55 @@ +; +; Marco van den Heuvel, 2018-04-27 +; + +; unsigned char detect_c65 (void); +; +;/* Check for the presence of a C65/C64DX in C64 mode. +; * +; * Possible return values: +; * 0x00 : C65/C64DX in C64 mode not present +; * 0x01 : C65/C64DX in C64 mode present +; */ + + .export _detect_c65 + + .include "accelerator.inc" + +_detect_c65: + ldy $D000 + +; Make sure the CPU is not a 65816 + clc + .byte $E2,$01 ; NOP #$01 on 6510 and 65(S)C02, LDA $(01,S),Y on 65CE02 and 4510, SEP #$01 on 65816 + lda #$00 + tax + bcs not_found ; carry will be set on 65816 + +; Make sure the CPU is not a 6510 + .byte $1A ; NOP on 6510, INA on 65(S)C(E)02 + beq not_found + txa + +; Make sure the CPU is a 65CE02/4510 + .byte $A3,$A3 ; NOP NOP on 65(S)C02, LDZ #$A3 on 65CE02 and 4510 + .byte $6B ; NOP on 65(S)C02, TZA on 65CE02 and 4510 + cmp #$A3 + bne not_found + +; Switch to VICIII mode and check if $D040 is a mirror of $D000 + ldy #C65_VICIII_UNLOCK_1 + sty C65_VICIII_KEY + ldy #C65_VICIII_UNLOCK_2 + sty C65_VICIII_KEY + cpy $D040 + bne found + inc $D000 + cpy $D040 + bne not_found + +found: + lda #$01 +not_found: + sty $D000 + sta C65_VICIII_KEY + rts diff --git a/libsrc/c64/acc_detect_chameleon.s b/libsrc/c64/acc_detect_chameleon.s new file mode 100755 index 000000000..a16a264e7 --- /dev/null +++ b/libsrc/c64/acc_detect_chameleon.s @@ -0,0 +1,39 @@ +; +; Marco van den Heuvel, 2018-04-25 +; + +; unsigned char detect_chameleon (void); +; +;/* Check for the presence of the Chameleon cartridge. +; * +; * Possible return values: +; * 0x00 : Chameleon cartridge not present +; * 0x01 : Chameleon cartridge present +; */ + + .export _detect_chameleon + + .include "accelerator.inc" + +_detect_chameleon: + lda #$00 + tax + +; Make sure the CPU is a 6510 + .byte $1A ; NOP on 6510, INA on 65(S)C(E)02, 4510 and 65816 + bne not_found + + ldy CHAMELEON_CFGENA + lda #CHAMELEON_ENABLE_REGS + sta CHAMELEON_CFGENA + lda CHAMELEON_CFGENA + sty CHAMELEON_CFGENA + cmp #$FF + beq not_found +found: + lda #$01 + .byte $24 +not_found: + txa + rts + diff --git a/libsrc/c64/acc_detect_scpu.s b/libsrc/c64/acc_detect_scpu.s new file mode 100644 index 000000000..e42d90548 --- /dev/null +++ b/libsrc/c64/acc_detect_scpu.s @@ -0,0 +1,34 @@ +; +; Marco van den Heuvel, 2018-04-08 +; + +; unsigned char detect_scpu (void); +; +;/* Check for the presence of the SuperCPU cartridge. +; * +; * Possible return values: +; * 0x00 : SuperCPU cartridge not present +; * 0x01 : SuperCPU cartridge present +; */ + + .export _detect_scpu + + .include "accelerator.inc" +_detect_scpu: + ldx #$00 + txa + +; Make sure the current CPU is a 65816 + clc + .byte $E2,$01 ; NOP #$01 on 6510 and 65(S)C02, LDA $(01,S),Y on 65CE02 and 4510, SEP #$01 on 65816 + bcc not_found ; carry will be set on 65816 + +; 65816 has been detected, make sure it's the SuperCPU cartridge + + lda SuperCPU_Detect + asl + bcs not_found +found: + lda #$01 +not_found: + rts diff --git a/libsrc/c64/acc_detect_turbomaster.s b/libsrc/c64/acc_detect_turbomaster.s new file mode 100755 index 000000000..431985a47 --- /dev/null +++ b/libsrc/c64/acc_detect_turbomaster.s @@ -0,0 +1,45 @@ +; +; Marco van den Heuvel, 2018-04-30 +; + +; unsigned char detect_turbomaster (void); +; +;/* Check for the presence of a Turbo Master cartridge. +; * +; * Possible return values: +; * 0x00 : TurboMaster cartridge not present +; * 0x01 : TurboMaster cartridge present +; */ + + .export _detect_turbomaster + + .include "accelerator.inc" + +_detect_turbomaster: + lda #$00 + tax + +; Make sure the current CPU is not a 6510 + .byte $1A ; NOP on 8502, INA on 65(S)C(E)02, 4510 and 65816 + beq not_found + +; Make sure the current CPU is not a 65816 + clc + .byte $E2,$01 ; NOP #$01 on 65(S)C02, LDA $(01,S),Y on 65CE02 and 4510, SEP #$01 on 65816 + bcs not_found ; carry will be set on 65816 + +; Make sure the current CPU is not a 65CE02/4510 + .byte $A3,$A3 ; NOP NOP on 65(S)C02 and LDZ #$00 on 65CE02 and 4510 + .byte $6B ; NOP on 65(S)C02 and TZA on 65CE02 and 4510 + cmp #$A3 + beq not_found + +; Check for turbo master basic replacement + ldy TURBOMASTER_DETECT + cpy #$A2 + beq found +not_found: + txa +found: + rts + diff --git a/libsrc/c64/acc_scpu_speed.s b/libsrc/c64/acc_scpu_speed.s new file mode 100644 index 000000000..9f932aecd --- /dev/null +++ b/libsrc/c64/acc_scpu_speed.s @@ -0,0 +1,59 @@ +; +; Marco van den Heuvel, 2018-04-09 +; + +; unsigned char __fastcall__ set_scpu_speed (unsigned char speed); +; +;/* Set the speed of the SuperCPU cartridge, using SPEED_SLOW will switch to +; * 1 Mhz mode, SPEED_20X or SPEED_FAST will switch to 20 Mhz mode. +; * +; * Note that any value lower than SPEED_20X will switch to 1 Mhz mode, and +; * any value higher or equal to SPEED_20X will switch to 20 Mhz mode. +; * +; * This function will return the actual speed the CPU is at after trying +; * to set the requested speed, if this is not the speed that was requested +; * then possibly the hardware speed switch prevented any software speed +; * switching. +; * +; * This function does not check for the presence of the SuperCPU cartridge, +; * make sure you use 'detect_scpu();' before using. +; */ + +; unsigned char get_scpu_speed (void); +; +;/* Get the speed of the SuperCPU cartridge. +; * +; * Possible return values: +; * SPEED_1X : 1 Mhz mode +; * SPEED_20X : 20 Mhz mode +; * +; * This function does not check for the presence of the SuperCPU cartridge, +; * make sure you use 'detect_scpu();' before using. +; */ + + .export _set_scpu_speed + .export _get_scpu_speed + + .include "accelerator.inc" + +_set_scpu_speed: + cmp #SPEED_20X + bcs high_speed +low_speed: + sta SuperCPU_Slow + jmp _get_scpu_speed + +high_speed: + sta SuperCPU_Fast + +_get_scpu_speed: + ldx #$00 + lda SuperCPU_Speed_Mode + asl + asl + bcc is_fast_speed + lda #SPEED_1X + rts +is_fast_speed: + lda #SPEED_20X + rts diff --git a/libsrc/c64/acc_turbomaster_speed.s b/libsrc/c64/acc_turbomaster_speed.s new file mode 100755 index 000000000..7ef6b0540 --- /dev/null +++ b/libsrc/c64/acc_turbomaster_speed.s @@ -0,0 +1,56 @@ +; +; Marco van den Heuvel, 2018-04-30 +; + +; unsigned char __fastcall__ set_turbomaster_speed (unsigned char speed); +; +;/* Set the speed of the Turbo Master cartridge, using SPEED_SLOW will switch to +; * 1 Mhz mode, SPEED_4X or SPEED_FAST will switch to 4 Mhz mode. +; * +; * Note that any value higher or equal to SPEED_4X will switch to 4 Mhz mode, +; * any value lower than SPEED_4X will switch to 1 Mhz mode. +; * +; * This function will return the actual speed the CPU is at after trying +; * to set the requested speed, if the speed is different it might indicate +; * that the hardware switch has locked the speed. +; * +; * This function does not check for the presence of a Turbo Master cartridge, +; * make sure you use 'detect_turbomaster();' before using. +; */ + +; unsigned char get_turbomaster_speed (void); +; +;/* Get the speed of the Turbo Master cartridge. +; * +; * Possible return values: +; * SPEED_SLOW : 1 Mhz mode +; * SPEED_4X : 4 Mhz mode +; * +; * This function does not check for the presence of a Turbo Master cartridge, +; * make sure you use 'detect_turbomaster();' before using. +; */ + + .export _set_turbomaster_speed + .export _get_turbomaster_speed + + .include "accelerator.inc" + +_set_turbomaster_speed: + tay + lda TURBOMASTER_SPEED_REG + asl + cpy #SPEED_4X + ror +store_speed: + sta TURBOMASTER_SPEED_REG + +_get_turbomaster_speed: + ldx #$00 + lda TURBOMASTER_SPEED_REG + and #$80 + beq is_slow_speed +is_high_speed: + lda #SPEED_4X +is_slow_speed: + rts + diff --git a/libsrc/c64/emd/c64-ram.s b/libsrc/c64/emd/c64-ram.s index f8a4a1819..b41f932e6 100644 --- a/libsrc/c64/emd/c64-ram.s +++ b/libsrc/c64/emd/c64-ram.s @@ -44,7 +44,7 @@ ; Constants BASE = $D000 -PAGES = ($10000 - BASE) / 256 +PAGES = ($FF00 - BASE) / 256 ; ------------------------------------------------------------------------ ; Data. @@ -267,5 +267,3 @@ COPYTO: sta ptr3 sta ptr1+1 ; From jmp common - - diff --git a/libsrc/c64/emd/c64-reu.s b/libsrc/c64/emd/c64-reu.s index 0779505be..bf7bb4fb0 100644 --- a/libsrc/c64/emd/c64-reu.s +++ b/libsrc/c64/emd/c64-reu.s @@ -55,6 +55,9 @@ REU_TRIGGER = $FF00 ; REU command trigger OP_COPYFROM = $ED OP_COPYTO = $EC +OP_COPYFROM_ALOAD = $B1 +OP_COPYTO_ALOAD = $B0 + ; ------------------------------------------------------------------------ ; Data. @@ -92,19 +95,59 @@ INSTALL: cmp REU_REUADDR ; Check for presence of REU bne nodevice - ldy #>(128*4) ; Assume 128KB - lda REU_STATUS - and #$10 ; Check size bit - beq @L1 - ldy #>(256*4) ; 256KB when size bit is set -@L1: sty pagecount+1 - +; determine the size + php + sei ldy #$FF - sty curpage - sty curpage+1 ; Invalidate the current page - txa ; X = A = EM_ERR_OK +loop: + sty window + jsr reu_size_check_common + ldx #OP_COPYTO_ALOAD + stx REU_COMMAND + dey + cpy #$FF + bne loop + iny +size_loop: + jsr reu_size_check_common + ldx #OP_COPYFROM_ALOAD + stx REU_COMMAND + cpy window + bne size_found + iny + bne size_loop +size_found: + plp + ldx #$00 + cpy #$00 ; too many pages, shave off 2 + bne pagecount_ok + dex + dex + dey +pagecount_ok: + stx pagecount + sty pagecount+1 + lda #<EM_ERR_OK + ldx #>EM_ERR_OK rts +; common REU setup for size check +reu_size_check_common: + sty REU_REUADDR+2 + ldx #<window + stx REU_C64ADDR + ldx #>window + stx REU_C64ADDR+1 + ldx #$00 + stx REU_REUADDR + stx REU_REUADDR+1 + stx REU_COUNT+1 + stx REU_CONTROL + inx + stx REU_COUNT + rts + + ; No REU found nodevice: diff --git a/libsrc/c64/extra/soft80.s b/libsrc/c64/extra/soft80.s index d445c85c0..0ea28cfaf 100644 --- a/libsrc/c64/extra/soft80.s +++ b/libsrc/c64/extra/soft80.s @@ -15,6 +15,22 @@ .export _textcolor := soft80_textcolor ; color.s .export _bgcolor := soft80_bgcolor ; color.s + ; soft80_cpeekc.s + .import soft80_cpeekc + .export _cpeekc := soft80_cpeekc ; cpeekc.s + + ; soft80_cpeekcolor.s + .import soft80_cpeekcolor + .export _cpeekcolor := soft80_cpeekcolor ; cpeekcolor.s + + ; soft80_cpeekrevers.s + .import soft80_cpeekrevers + .export _cpeekrevers := soft80_cpeekrevers ; cpeekrevers.s + + ; soft80_cpeeks.s + .import soft80_cpeeks + .export _cpeeks := soft80_cpeeks ; cpeeks.s + ; soft80_cputc.s .import soft80_cputc .import soft80_cputcxy @@ -50,3 +66,6 @@ ; Chars used by chline () and cvline () .exportzp chlinechar = CH_HLINE .exportzp cvlinechar = CH_VLINE + + .import return1 + .export _doesclrscrafterexit := return1 diff --git a/libsrc/c64/extra/soft80mono.s b/libsrc/c64/extra/soft80mono.s index 6fd2c687c..700cbcb6c 100644 --- a/libsrc/c64/extra/soft80mono.s +++ b/libsrc/c64/extra/soft80mono.s @@ -18,6 +18,22 @@ .export _textcolor := soft80mono_textcolor ; color.s .export _bgcolor := soft80mono_bgcolor ; color.s + ; soft80mono_cpeekc.s + .import soft80_cpeekc + .export _cpeekc := soft80_cpeekc ; cpeekc.s + + ; soft80mono_cpeekcolor.s + .import soft80mono_cpeekcolor + .export _cpeekcolor := soft80mono_cpeekcolor ; cpeekcolor.s + + ; soft80mono_cpeekrevers.s + .import soft80_cpeekrevers + .export _cpeekrevers := soft80_cpeekrevers ; cpeekrevers.s + + ; soft80mono_cpeeks.s + .import soft80_cpeeks + .export _cpeeks := soft80_cpeeks ; cpeeks.s + ; soft80mono_cputc.s .import soft80mono_cputc .import soft80mono_cputcxy @@ -53,3 +69,6 @@ ; Chars used by chline () and cvline () .exportzp chlinechar = CH_HLINE .exportzp cvlinechar = CH_VLINE + + .import return1 + .export _doesclrscrafterexit := return1 diff --git a/libsrc/c64/joy/c64-hitjoy.s b/libsrc/c64/joy/c64-hitjoy.s index 10c936399..3b4a0b909 100644 --- a/libsrc/c64/joy/c64-hitjoy.s +++ b/libsrc/c64/joy/c64-hitjoy.s @@ -35,7 +35,6 @@ .addr UNINSTALL .addr COUNT .addr READ - .addr IRQ ; ------------------------------------------------------------------------ ; Constants @@ -74,13 +73,22 @@ UNINSTALL: rts ; ------------------------------------------------------------------------ -; IRQ entry point. Is called from the C layer as a subroutine in the -; interrupt. The routine MUST return carry set if the interrupt has been -; 'handled' - which means that the interrupt source is gone. Otherwise it -; MUST return carry clear. +; COUNT: Return the total number of available joysticks in a/x. +; -IRQ: ; cia 2 setup +COUNT: lda #<JOY_COUNT + ldx #>JOY_COUNT + rts +; ------------------------------------------------------------------------ +; READ: Read a particular joystick passed in A. +; + +readadapter: + + sei + + ; cia 2 setup ldy #$00 ; port b direction sty $dd03 ; => input @@ -144,32 +152,24 @@ IRQ: ; cia 2 setup sta temp4 fire: - ; Default Value: $40/64 on PAL - ; $42/66 on NTSC + ; FIXME: to be really 100% correct this should restore the correct timer + ; values for the respective machine (PAL: $4025, NTSC: $4295) + ; however, this should hardly be a problem in a real world program + lda #$41 sta $dc05 - ; Default Value: $25/37 on PAL - ; $95/149 on NTSC lda #0 sta $dc04 - ; We do never "handle" the interrupt, we use it just as a timer. - clc + cli rts -; ------------------------------------------------------------------------ -; COUNT: Return the total number of available joysticks in a/x. -; +READ: + pha + jsr readadapter + pla -COUNT: lda #<JOY_COUNT - ldx #>JOY_COUNT - rts - -; ------------------------------------------------------------------------ -; READ: Read a particular joystick passed in A. -; - -READ: tax ; Joystick number into X + tax ; Joystick number into X bne joy2 ; Read joystick 1 @@ -215,4 +215,3 @@ joy4: lda temp4 eor #$1F ldx #0 rts - diff --git a/libsrc/c64/joy/c64-numpad.s b/libsrc/c64/joy/c64-numpad.s index 5ed7af187..0ccdc4fcd 100644 --- a/libsrc/c64/joy/c64-numpad.s +++ b/libsrc/c64/joy/c64-numpad.s @@ -36,7 +36,6 @@ .addr UNINSTALL .addr COUNT .addr READ - .addr 0 ; IRQ entry unused ; ------------------------------------------------------------------------ ; Constants diff --git a/libsrc/c64/joy/c64-ptvjoy.s b/libsrc/c64/joy/c64-ptvjoy.s index af5c27e13..a772fb5f6 100644 --- a/libsrc/c64/joy/c64-ptvjoy.s +++ b/libsrc/c64/joy/c64-ptvjoy.s @@ -35,7 +35,6 @@ .addr UNINSTALL .addr COUNT .addr READ - .addr 0 ; IRQ entry unused ; ------------------------------------------------------------------------ ; Constants diff --git a/libsrc/c64/joy/c64-stdjoy.s b/libsrc/c64/joy/c64-stdjoy.s index 930ad6227..c983d81bb 100644 --- a/libsrc/c64/joy/c64-stdjoy.s +++ b/libsrc/c64/joy/c64-stdjoy.s @@ -35,7 +35,6 @@ .addr UNINSTALL .addr COUNT .addr READ - .addr 0 ; IRQ entry unused ; ------------------------------------------------------------------------ ; Constants diff --git a/libsrc/c64/soft80_cpeekc.s b/libsrc/c64/soft80_cpeekc.s new file mode 100644 index 000000000..576d50fc1 --- /dev/null +++ b/libsrc/c64/soft80_cpeekc.s @@ -0,0 +1,148 @@ +; +; 2017-12-28, Groepaz +; +; char cpeekc (void); +; + + .export soft80_cpeekc, soft80_cpeekchar + + .include "c64.inc" + .include "soft80.inc" + + .macpack longbranch + + .segment "CODE" + +soft80_cpeekc: + jsr soft80_cpeekchar + ; 0-1F -> A0-BF + ; 20-7F -> 20-7F + cmp #$20 + bcs @sk + ;clc + adc #$a0 +@sk: + ldx #0 + rts + +soft80_cpeekchar: + + sei + lda #$34 + sta $01 + + lda CURS_X + and #$01 + + jne @l1a + + ; test non-inverted character (left side) + + ldx #0 +@l2aa: + ldy #0 + + .repeat 8,line + lda (SCREEN_PTR),y + and #$f0 + cmp soft80_hi_charset+(line*$80),x + bne @l2b + .if (line < 7) + iny + .endif + .endrepeat + +@backok: + lda #$36 + sta $01 + cli + txa ; return char in A + ldx #$00 ; revers flag + rts +@l2b: + inx + cpx #$80 + jne @l2aa + + ; test inverted character (left side) + + ldx #0 +@l2aa2: + ldy #0 + + .repeat 8,line + lda (SCREEN_PTR),y + and #$f0 + eor #$f0 + cmp soft80_hi_charset+(line*$80),x + bne @l2b2 + .if (line < 7) + iny + .endif + .endrepeat + +@backokrevers: + lda #$36 + sta $01 + cli + txa ; return char in A + ldx #$01 ; revers flag + rts + +@l2b2: + inx + cpx #$80 + jne @l2aa2 + +@backerr: + lda #$36 + sta $01 + cli + ldx #0 + txa + rts + + ; test non-inverted character (right side) + +@l1a: + ldx #0 +@l1aa: + ldy #0 + .repeat 8,line + lda (SCREEN_PTR),y + and #$0f + eor soft80_lo_charset+(line*$80),x + bne @l2bb + .if line < 7 + iny + .endif + .endrepeat + jmp @backok +@l2bb: + inx + cpx #$80 + bne @l1aa + + ; test inverted character (right side) + + ldx #0 +@l1aa2: + ldy #0 + .repeat 8,line + lda (SCREEN_PTR),y + and #$0f + eor #$0f + eor soft80_lo_charset+(line*$80),x + bne @l2bb2 + .if line < 7 + iny + .endif + .endrepeat + jmp @backokrevers +@l2bb2: + inx + cpx #$80 + bne @l1aa2 + + jmp @backerr + diff --git a/libsrc/c64/soft80_cpeekcolor.s b/libsrc/c64/soft80_cpeekcolor.s new file mode 100644 index 000000000..c8f1c6e43 --- /dev/null +++ b/libsrc/c64/soft80_cpeekcolor.s @@ -0,0 +1,19 @@ +; +; 2017-12-27, Groepaz +; +; unsigned char cpeekcolor (void); +; + + .export soft80_cpeekcolor + + .include "c64.inc" + .include "soft80.inc" + + .segment "CODE" + +soft80_cpeekcolor: + ldy #0 + lda (CRAM_PTR),y + and #$0f + ldx #0 + rts diff --git a/libsrc/c64/soft80_cpeekrevers.s b/libsrc/c64/soft80_cpeekrevers.s new file mode 100644 index 000000000..779636ed5 --- /dev/null +++ b/libsrc/c64/soft80_cpeekrevers.s @@ -0,0 +1,15 @@ +; +; 2017-12-28, Groepaz +; +; unsigned char cpeekrevers (void); +; + + .import soft80_cpeekchar + + .export soft80_cpeekrevers + +soft80_cpeekrevers: + jsr soft80_cpeekchar + txa + ldx #0 + rts diff --git a/libsrc/c64/soft80_cpeeks.s b/libsrc/c64/soft80_cpeeks.s new file mode 100644 index 000000000..837afef1e --- /dev/null +++ b/libsrc/c64/soft80_cpeeks.s @@ -0,0 +1,71 @@ +; +; 2017-12-27, groepaz +; +; void cpeeks (char* s, unsigned length); +; + .export soft80_cpeeks + .import soft80_cpeekc, soft80_kplot, popax + + .importzp ptr1, ptr2 + + .include "c64.inc" + .include "soft80.inc" + +soft80_cpeeks: + eor #<$FFFF ; counting a word upward is faster + sta ptr2 ; so, we use -(length + 1) + txa + eor #>$FFFF + sta ptr2+1 + + jsr popax + sta ptr1 + stx ptr1+1 + + ; save current cursor position + lda CURS_X + pha + lda CURS_Y + pha + + ; get the string +@lp: + jsr soft80_cpeekc + ldy #0 + sta (ptr1),y + + ; advance cursor position + ldy CURS_X + ldx CURS_Y + iny + cpy #charsperline + bne @sk2 + ldy #0 + inx +@sk2: + sty CURS_X + stx CURS_Y + clc + jsr soft80_kplot + + inc ptr1 + bne @sk + inc ptr1+1 +@sk: + inc ptr2 + bne @lp + inc ptr2+1 + bne @lp + + ; terminate the string + lda #0 + ldy #0 + sta (ptr1),y + + ; restore the cursor position + pla + tax ; CURS_Y + pla + tay ; CURS_X + clc + jmp soft80_kplot diff --git a/libsrc/c64/soft80mono_cpeekcolor.s b/libsrc/c64/soft80mono_cpeekcolor.s new file mode 100644 index 000000000..a03875a74 --- /dev/null +++ b/libsrc/c64/soft80mono_cpeekcolor.s @@ -0,0 +1,17 @@ +; +; 2017-12-27, Groepaz +; +; unsigned char cpeekcolor (void); +; + + .export soft80mono_cpeekcolor + + .include "c64.inc" + .include "soft80.inc" + + .segment "CODE" + +soft80mono_cpeekcolor: + lda CHARCOLOR + ldx #0 + rts diff --git a/libsrc/c64/tgi/c64-hi.s b/libsrc/c64/tgi/c64-hi.s index 580220ecc..e2c3bca9f 100644 --- a/libsrc/c64/tgi/c64-hi.s +++ b/libsrc/c64/tgi/c64-hi.s @@ -4,6 +4,7 @@ ; Based on Stephen L. Judd's GRLIB code. ; ; 2017-01-13, Greg King +; 2018-03-13, Sven Klose ; .include "zeropage.inc" @@ -57,7 +58,6 @@ .addr BAR .addr TEXTSTYLE .addr OUTTEXT - .addr 0 ; IRQ entry is unused ; ------------------------------------------------------------------------ ; Data. @@ -71,12 +71,9 @@ X2 := ptr3 Y2 := ptr4 TEXT := ptr3 -ROW := tmp2 ; Bitmap row... -COL := tmp3 ; ...and column, both set by PLOT TEMP := tmp4 TEMP2 := sreg POINT := regsave -INRANGE := regsave+2 ; PLOT variable, $00 = coordinates in range CHUNK := X2 ; Used in the line routine OLDCHUNK := X2+1 ; Dito @@ -134,7 +131,7 @@ VBASE := $E000 ; Video memory base address ; INSTALL: - rts +; rts ; fall through ; ------------------------------------------------------------------------ @@ -275,7 +272,7 @@ CLEAR: ldy #$00 sta VBASE+$1C00,y sta VBASE+$1D00,y sta VBASE+$1E00,y - sta VBASE+$1F00,y + sta VBASE+$1E40,y ; preserve vectors iny bne @L1 rts @@ -288,7 +285,7 @@ CLEAR: ldy #$00 ; SETVIEWPAGE: - rts +; rts ; fall through ; ------------------------------------------------------------------------ ; SETDRAWPAGE: Set the drawable page. Called with the new page in A (0..n). @@ -455,11 +452,6 @@ GETPIXEL: ; LINE: Draw a line from X1/Y1 to X2/Y2, where X1/Y1 = ptr1/ptr2 and ; X2/Y2 = ptr3/ptr4 using the current drawing color. ; -; To deal with off-screen coordinates, the current row -; and column (40x25) is kept track of. These are set -; negative when the point is off the screen, and made -; positive when the point is within the visible screen. -; ; X1,X2 etc. are set up above (x2=LINNUM in particular) ; Format is LINE x2,y2,x1,y1 ; @@ -514,7 +506,7 @@ LINE: stx YINCDEC stx XINCDEC - jsr CALC ; Set up .X,.Y,POINT, and INRANGE + jsr CALC ; Set up .X, .Y, and POINT lda BITCHUNK,X sta OLDCHUNK sta CHUNK @@ -557,15 +549,11 @@ STEPINY: ; YLOOP: sta TEMP - lda INRANGE ;Range check - bne @SKIP - - lda (POINT),y ;Otherwise plot + lda (POINT),y eor BITMASK and CHUNK eor (POINT),y sta (POINT),y -@SKIP: YINCDEC: iny ;Advance Y coordinate cpy #8 @@ -582,7 +570,7 @@ YCONT2: lda (POINT),y ;Plot endpoint and CHUNK eor (POINT),y sta (POINT),y -YDONE: lda #$36 + lda #$36 sta $01 cli rts @@ -593,23 +581,12 @@ YFIXX: ;x=x+1 bne YCONT ;If we pass a column boundary... ror CHUNK ;then reset CHUNK to $80 sta TEMP2 - lda COL - bmi @C1 ;Skip if column is negative - cmp #39 ;End if move past end of screen - bcs YDONE -@C1: lda POINT ;And add 8 to POINT + lda POINT ;And add 8 to POINT adc #8 sta POINT bcc @CONT inc POINT+1 -@CONT: inc COL ;Increment column - bne @C2 - lda ROW ;Range check - cmp #25 - bcs @C2 - lda #00 ;Passed into col 0 - sta INRANGE -@C2: lda TEMP2 +@CONT: lda TEMP2 dex bne YLOOP beq YCONT2 @@ -648,7 +625,7 @@ XCONT2: dex dec COUNTHI ;High bits set? bpl XLOOP -XDONE: lsr CHUNK ;Advance to last point + lsr CHUNK ;Advance to last point jsr LINEPLOT ;Plot the last chunk EXIT: lda #$36 sta $01 @@ -663,25 +640,14 @@ XFIXC: sta TEMP lda #$FF sta CHUNK sta OLDCHUNK - lda COL - bmi @C1 ;Skip if column is negative - cmp #39 ;End if move past end of screen - bcs EXIT -@C1: lda POINT + lda POINT + clc adc #8 sta POINT - bcc @CONT + lda TEMP + bcc XCONT1 inc POINT+1 -@CONT: inc COL - bne @C2 - lda ROW - cmp #25 - bcs @C2 - lda #00 - sta INRANGE -@C2: lda TEMP - sec - bcs XCONT1 + jmp XCONT1 ; ; Check to make sure there isn't a high bit, plot chunk, ; and update Y-coordinate. @@ -713,17 +679,14 @@ XINCDEC: ; room, gray hair, etc.) ; LINEPLOT: ; Plot the line chunk - lda INRANGE - bne @SKIP - - lda (POINT),Y ; Otherwise plot + lda (POINT),Y eor BITMASK ora CHUNK and OLDCHUNK eor CHUNK eor (POINT),Y sta (POINT),Y -@SKIP: rts + rts ; ; Subroutine to fix up pointer when Y decreases through @@ -731,23 +694,16 @@ LINEPLOT: ; Plot the line chunk ; FIXY: cpy #255 ;Y=255 or Y=8 beq @DECPTR + @INCPTR: ;Add 320 to pointer ldy #0 ;Y increased through 7 - lda ROW - bmi @C1 ;If negative, then don't update - cmp #24 - bcs @TOAST ;If at bottom of screen then quit -@C1: lda POINT + lda POINT adc #<320 sta POINT lda POINT+1 adc #>320 sta POINT+1 -@CONT1: inc ROW - bne @DONE - lda COL - bpl @CLEAR -@DONE: rts + rts @DECPTR: ;Okay, subtract 320 then ldy #7 ;Y decreased through 0 @@ -758,21 +714,8 @@ FIXY: cpy #255 ;Y=255 or Y=8 lda POINT+1 sbc #>320 sta POINT+1 -@CONT2: dec ROW - bmi @TOAST - lda ROW - cmp #24 - bne @DONE - lda COL - bmi @DONE -@CLEAR: lda #00 - sta INRANGE rts -@TOAST: pla ;Remove old return address - pla - jmp EXIT ;Restore interrupts, etc. - ; ------------------------------------------------------------------------ ; BAR: Draw a filled rectangle with the corners X1/Y1, X2/Y2, where ; X1/Y1 = ptr1/ptr2 and X2/Y2 = ptr3/ptr4 using the current drawing color. @@ -897,48 +840,36 @@ OUTTEXT: rts ; ------------------------------------------------------------------------ -; Calculate all variables to plot the pixel at X1/Y1. If the point is out -; of range, a carry is returned and INRANGE is set to a value !0 zero. If -; the coordinates are valid, INRANGE is zero and the carry clear. +; Calculate all variables to plot the pixel at X1/Y1. CALC: lda Y1 - sta ROW + sta TEMP2 and #7 tay lda Y1+1 lsr ; Neg is possible - ror ROW + ror TEMP2 lsr - ror ROW + ror TEMP2 lsr - ror ROW + ror TEMP2 lda #00 sta POINT - lda ROW + lda TEMP2 cmp #$80 ror ror POINT cmp #$80 ror ror POINT ; row*64 - adc ROW ; +row*256 + adc TEMP2 ; +row*256 clc adc #>VBASE ; +bitmap base sta POINT+1 lda X1 tax - sta COL - lda X1+1 - lsr - ror COL - lsr - ror COL - lsr - ror COL - - txa and #$F8 clc adc POINT ; +(X AND #$F8) @@ -949,13 +880,4 @@ CALC: lda Y1 txa and #7 tax - - lda ROW - cmp #25 - bcs @L9 - lda COL - cmp #40 - bcs @L9 - lda #00 -@L9: sta INRANGE rts diff --git a/libsrc/c64/tgi_colors.s b/libsrc/c64/tgi_colors.s deleted file mode 100644 index 6ef3729b4..000000000 --- a/libsrc/c64/tgi_colors.s +++ /dev/null @@ -1,8 +0,0 @@ -; -; Target-specific black & white values for use by the target-shared TGI kernel -; - - .include "tgi-kernel.inc" - - .export tgi_color_black:zp = $00 - .export tgi_color_white:zp = $01 diff --git a/libsrc/cbm/c_untlk.s b/libsrc/cbm/c_untlk.s index 1d71c168b..3865564cd 100644 --- a/libsrc/cbm/c_untlk.s +++ b/libsrc/cbm/c_untlk.s @@ -1,11 +1,11 @@ ; ; Ullrich von Bassewitz, 03.06.1999 ; -; void cbm_untlk (void); +; void cbm_k_untlk (void); ; - .export _cbm_untlk + .export _cbm_k_untlk .import UNTLK -_cbm_untlk = UNTLK +_cbm_k_untlk = UNTLK diff --git a/libsrc/cbm/close.s b/libsrc/cbm/close.s index 004b88df9..b43c07b57 100644 --- a/libsrc/cbm/close.s +++ b/libsrc/cbm/close.s @@ -40,7 +40,7 @@ lda #LFN_CLOSED sta fdtab,x - lda tmp2 ; Get the handle + txa ; Get handle clc adc #LFN_OFFS ; Make LFN from handle jsr CLOSE diff --git a/libsrc/cbm/cpeekc.s b/libsrc/cbm/cpeekc.s new file mode 100644 index 000000000..05c7fc718 --- /dev/null +++ b/libsrc/cbm/cpeekc.s @@ -0,0 +1,53 @@ +; +; 2016-02-28, Groepaz +; 2017-06-22, Greg King +; +; char cpeekc (void); +; + + .export _cpeekc + +; Get a system-specific file. +; Note: The cbm610, and c128 targets need special +; versions that handle RAM banking and the 80-column VDC. + +.if .def(__C16__) + .include "plus4.inc" ; both C16 and Plus4 +.elseif .def(__C64__) + .include "c64.inc" +.elseif .def(__CBM510__) + .import CURS_X: zp, SCREEN_PTR: zp + .include "cbm510.inc" +.elseif .def(__PET__) + .include "pet.inc" +.elseif .def(__VIC20__) + .include "vic20.inc" +.endif + + +_cpeekc: + ldy CURS_X + lda (SCREEN_PTR),y ; get screen code + ldx #>$0000 + and #<~$80 ; remove reverse bit + +; Convert the screen code into a PetSCII code. +; $00 - $1F: +$40 +; $20 - $3F +; $40 - $5f: +$20 +; $60 - $7F: +$40 + + cmp #$20 + bcs @sk1 ;(bge) + ora #$40 + rts + +@sk1: cmp #$40 + bcc @end ;(blt) + cmp #$60 + bcc @sk2 ;(blt) + ;sec + adc #$20 - $01 +@sk2: ;clc ; both above cmp and adc clear carry flag + adc #$20 +@end: rts diff --git a/libsrc/cbm/cpeekcolor.s b/libsrc/cbm/cpeekcolor.s new file mode 100644 index 000000000..9c961b771 --- /dev/null +++ b/libsrc/cbm/cpeekcolor.s @@ -0,0 +1,28 @@ +; +; 2016-02-28, Groepaz +; 2017-06-22, Greg King +; +; unsigned char cpeekcolor (void); +; + + .export _cpeekcolor + +; Get a system-specific file. +; Note: The cbm510, cbm610, c128, and Pet targets need special +; versions that handle RAM banking, the 80-column VDC, and monochrome. + +.if .def(__C16__) + .include "plus4.inc" ; both C16 and Plus4 +.elseif .def(__C64__) + .include "c64.inc" +.elseif .def(__VIC20__) + .include "vic20.inc" +.endif + + +_cpeekcolor: + ldy CURS_X + lda (CRAM_PTR),y ; get color + and #$0F + ldx #>$0000 + rts diff --git a/libsrc/cbm/cpeekrevers.s b/libsrc/cbm/cpeekrevers.s new file mode 100644 index 000000000..e8e210167 --- /dev/null +++ b/libsrc/cbm/cpeekrevers.s @@ -0,0 +1,35 @@ +; +; 2016-02-28, Groepaz +; 2017-06-15, Greg King +; +; unsigned char cpeekrevers (void); +; + + .export _cpeekrevers + +; Get a system-specific file. +; Note: The cbm610, and c128 targets need special +; versions that handle RAM banking and the 80-column VDC. + +.if .def(__C16__) + .include "plus4.inc" ; both C16 and Plus4 +.elseif .def(__C64__) + .include "c64.inc" +.elseif .def(__CBM510__) + .import CURS_X: zp, SCREEN_PTR: zp + .include "cbm510.inc" +.elseif .def(__PET__) + .include "pet.inc" +.elseif .def(__VIC20__) + .include "vic20.inc" +.endif + + +_cpeekrevers: + ldy CURS_X + lda (SCREEN_PTR),y ; get screen code + and #$80 ; get reverse bit + asl a + tax ; ldx #>$0000 + rol a ; return boolean value + rts diff --git a/libsrc/cbm/cpeeks.s b/libsrc/cbm/cpeeks.s new file mode 100644 index 000000000..215998e37 --- /dev/null +++ b/libsrc/cbm/cpeeks.s @@ -0,0 +1,93 @@ +; +; 2017-07-05, Greg King +; +; void cpeeks (char* s, unsigned length); +; + + .export _cpeeks + + .import popax + .importzp ptr1, ptr2, ptr3, tmp1, tmp2 + + .macpack generic + +; Get a system-specific file. +; Note: The cbm610, and c128 targets need special +; versions that handle RAM banking and the 80-column VDC. + +.if .def(__C16__) + .include "plus4.inc" ; both C16 and Plus4 +.elseif .def(__C64__) + .include "c64.inc" +.elseif .def(__CBM510__) + .import CURS_X: zp, SCREEN_PTR: zp + .include "cbm510.inc" +.elseif .def(__PET__) + .include "pet.inc" +.elseif .def(__VIC20__) + .include "vic20.inc" +.endif + + +_cpeeks: + eor #<$FFFF ; counting a word upward is faster + sta ptr3 ; so, we use -(length + 1) + txa + eor #>$FFFF + sta ptr3+1 + + lda SCREEN_PTR + ldx SCREEN_PTR+1 + sta ptr2 + stx ptr2+1 + ldy CURS_X + sty tmp2 + + jsr popax + sta tmp1 ; (will be a .Y index) + stx ptr1+1 + ldx #<$0000 + stx ptr1 + bze L3 ; branch always + +L4: ldy tmp2 + lda (ptr2),y ; get char + iny + bnz L2 + inc ptr2+1 +L2: sty tmp2 + and #<~$80 ; remove reverse bit + +; Convert the screen code into a PetSCII code. +; $00 - $1F: +$40 +; $20 - $3F +; $40 - $5f: +$20 +; $60 - $7F: +$40 + + cmp #$20 + blt @sk1 ;(bcc) + cmp #$40 + blt L5 + cmp #$60 + blt @sk2 ;(bcc) + clc +@sk1: adc #$20 +@sk2: ;clc ; both above cmp and adc clear carry flag + adc #$20 + +L5: ldy tmp1 + sta (ptr1),y + iny + bnz L1 + inc ptr1+1 +L1: sty tmp1 + +L3: inc ptr3 ; count length + bnz L4 + inc ptr3+1 + bnz L4 + + txa ; terminate the string + ldy tmp1 + sta (ptr1),y + rts diff --git a/libsrc/cbm/open.s b/libsrc/cbm/open.s index 4e57f5efc..5c97aff56 100644 --- a/libsrc/cbm/open.s +++ b/libsrc/cbm/open.s @@ -2,10 +2,6 @@ ; Ullrich von Bassewitz, 16.11.2002 ; ; int open (const char* name, int flags, ...); /* May take a mode argument */ -; -; Be sure to keep the value priority of closeallfiles lower than that of -; closeallstreams (which is the high level C file I/O counterpart and must be -; called before closeallfiles). .export _open diff --git a/libsrc/cbm510/cpeekcolor.s b/libsrc/cbm510/cpeekcolor.s new file mode 100644 index 000000000..44c0a1595 --- /dev/null +++ b/libsrc/cbm510/cpeekcolor.s @@ -0,0 +1,24 @@ +; +; 2016-02-28, Groepaz +; 2017-06-19, Greg King +; +; unsigned char cpeekcolor (void); +; + + .export _cpeekcolor + + .import CURS_X: zp, CRAM_PTR: zp + + .include "cbm510.inc" + + +_cpeekcolor: + ldx IndReg + lda #$0F + sta IndReg + ldy CURS_X + lda (CRAM_PTR),y ; get color + stx IndReg + and #$0F + ldx #>$0000 + rts diff --git a/libsrc/cbm510/doesclrscr.s b/libsrc/cbm510/doesclrscr.s new file mode 100644 index 000000000..e0f57374c --- /dev/null +++ b/libsrc/cbm510/doesclrscr.s @@ -0,0 +1,16 @@ +; +; 2016-06, Christian Groessler +; 2017-07-05, Greg King +; +; unsigned char doesclrscrafterexit (void); +; +; Returns 0/1 if, after program termination, the screen isn't/is cleared. +; + + .import return1 + +; cc65's CBM510 programs switch to a display screen in the program RAM bank; +; then, they switch back to the system bank when they exit. +; The screen is cleared. + + .export _doesclrscrafterexit := return1 diff --git a/libsrc/cbm510/joy/cbm510-std.s b/libsrc/cbm510/joy/cbm510-std.s index 0c2efc12d..4e47fc1a0 100644 --- a/libsrc/cbm510/joy/cbm510-std.s +++ b/libsrc/cbm510/joy/cbm510-std.s @@ -36,7 +36,6 @@ .addr UNINSTALL .addr COUNT .addr READ - .addr 0 ; IRQ entry unused ; ------------------------------------------------------------------------ ; Constants diff --git a/libsrc/cbm610/cpeekc.s b/libsrc/cbm610/cpeekc.s new file mode 100644 index 000000000..295d096f3 --- /dev/null +++ b/libsrc/cbm610/cpeekc.s @@ -0,0 +1,45 @@ +; +; 2016-02-28, Groepaz +; 2017-06-19, Greg King +; +; char cpeekc (void); +; + + .export _cpeekc + + .import CURS_X: zp, CharPtr: zp + + .include "cbm610.inc" + + +_cpeekc: + ldx IndReg + ldy #$0F + sty IndReg + + ldy CURS_X + lda (CharPtr),y ; get char from system bank + stx IndReg + ldx #>$0000 + and #<~$80 ; remove reverse bit + +; Convert the screen code into a PetSCII code. +; $00 - $1F: +$40 +; $20 - $3F +; $40 - $5f: +$20 +; $60 - $7F: +$40 + + cmp #$20 + bcs @sk1 ;(bge) + ora #$40 + rts + +@sk1: cmp #$40 + bcc @end ;(blt) + cmp #$60 + bcc @sk2 ;(blt) + ;sec + adc #$20 - $01 +@sk2: ;clc ; both above cmp and adc clear carry flag + adc #$20 +@end: rts diff --git a/libsrc/cbm610/cpeekcolor.s b/libsrc/cbm610/cpeekcolor.s new file mode 100644 index 000000000..ed275ec95 --- /dev/null +++ b/libsrc/cbm610/cpeekcolor.s @@ -0,0 +1,8 @@ +; +; 2017-06-03, Greg King +; +; unsigned char cpeekcolor (void); +; + + .import return1 + .export _cpeekcolor := return1 ; always COLOR_WHITE diff --git a/libsrc/cbm610/cpeekrevers.s b/libsrc/cbm610/cpeekrevers.s new file mode 100644 index 000000000..52e166e85 --- /dev/null +++ b/libsrc/cbm610/cpeekrevers.s @@ -0,0 +1,29 @@ +; +; 2016-02-28, Groepaz +; 2017-06-19, Greg King +; +; unsigned char cpeekrevers (void); +; + + .export _cpeekrevers + + .import plot + .import CURS_X: zp, CharPtr: zp + + .include "cbm610.inc" + + +_cpeekrevers: + ldx IndReg + ldy #$0F + sty IndReg + + ldy CURS_X + lda (CharPtr),y ; get char from system bank + stx IndReg + ldx #>$0000 + and #$80 ; get reverse bit + asl a + tax ; ldx #>$0000 + rol a ; return boolean value + rts diff --git a/libsrc/cbm610/cpeeks.s b/libsrc/cbm610/cpeeks.s new file mode 100644 index 000000000..352521bcc --- /dev/null +++ b/libsrc/cbm610/cpeeks.s @@ -0,0 +1,82 @@ +; +; 2017-07-05, Greg King +; +; void cpeeks (char* s, unsigned length); +; + + .export _cpeeks + + .import popax + .importzp ptr1, ptr2, ptr3, tmp1, tmp2 + .importzp CURS_X, CharPtr + + .include "cbm610.inc" + .macpack generic + + +_cpeeks: + eor #<$FFFF ; counting a word upward is faster + sta ptr3 ; so, we use -(length + 1) + txa + eor #>$FFFF + sta ptr3+1 + + lda CharPtr + ldx CharPtr+1 + sta ptr2 + stx ptr2+1 + ldy CURS_X + sty tmp2 + + jsr popax + sta tmp1 ; (will be a .Y index) + stx ptr1+1 + ldx IndReg + ldy #<$0000 + sty ptr1 + bze L3 ; branch always + +L4: ldy #$0F + sty IndReg + ldy tmp2 + lda (ptr2),y ; get char from system bank + stx IndReg + iny + bnz L2 + inc ptr2+1 +L2: sty tmp2 + and #<~$80 ; remove reverse bit + +; Convert the screen code into a PetSCII code. +; $00 - $1F: +$40 +; $20 - $3F +; $40 - $5f: +$20 +; $60 - $7F: +$40 + + cmp #$20 + blt @sk1 ;(bcc) + cmp #$40 + blt L5 + cmp #$60 + blt @sk2 ;(bcc) + clc +@sk1: adc #$20 +@sk2: ;clc ; both above cmp and adc clear carry flag + adc #$20 + +L5: ldy tmp1 + sta (ptr1),y + iny + bnz L1 + inc ptr1+1 +L1: sty tmp1 + +L3: inc ptr3 ; count length + bnz L4 + inc ptr3+1 + bnz L4 + + lda #$00 ; terminate the string + ldy tmp1 + sta (ptr1),y + rts diff --git a/libsrc/common/getcpu.s b/libsrc/common/getcpu.s index 1e60a5d39..169c56bbd 100644 --- a/libsrc/common/getcpu.s +++ b/libsrc/common/getcpu.s @@ -10,9 +10,13 @@ ; Subroutine to detect an 816. Returns ; ; - carry clear and 0 in A for a NMOS 6502 CPU -; - carry set and 1 in A for some CMOS 6502 CPU +; - carry set and 1 in A for a 65C02 ; - carry set and 2 in A for a 65816 ; - carry set and 3 in A for a 4510 +; - carry set and 4 in A for a 65SC02 +; - carry set and 5 in A for a 65CE02 +; - carry set and 6 in A for a HuC6280 +; - carry clear and 7 in A for a 2a03/2a07 ; ; This function uses a $1A opcode which is a INA on the 816 and ignored ; (interpreted as a NOP) on a NMOS 6502. There are several CMOS versions @@ -25,22 +29,62 @@ _getcpu: lda #0 inc a ; .byte $1A ; nop on nmos, inc on every cmos cmp #1 - bcc @L9 + bcc @L8 -; This is at least a 65C02, check for a 4510 +; This is at least a 65C02, check for a 65CE02/4510 - .byte $42,$ea ; neg on 4510, nop #$ea on 65c02, wdm $ea on 65816 + .byte $42,$EA ; neg on 65CE02/4510, nop #$EA on 65C02, wdm $EA on 65816 cmp #1 - bne @L8 + beq @L6 -; check for 65816; after 4510, because $eb there is row (rotate word) +; This is at least a 65CE02, check for 4510 + + lda #5 ; CPU_65CE02 constant + .byte $5C ; map on 4510, aug on 65CE02 (acts like 4 byte nop) + lda #3 ; CPU_4510 constant + nop + bne @L9 + +; 6502 type of cpu, check for a 2a03/2a07 +@L8: + sed ; set decimal mode, no decimal mode on the 2a03/2a07 + lda #9 + clc + adc #1 ; $01+$09 = $10 on 6502, $01+$09 = $0A on 2a03/2a07 + cld + cmp #$0a + beq @L5 + lda #0 ; CPU_6502 constant + beq @L9 +@L5: + lda #7 ; CPU_2A0x constant + bne @L9 + +; 65C02 cpu type, check for HuC6280 +@L4: ldx #6 ; CPU_HUC6280 constant + .byte $22,$EA ; sax nop on HuC6280 (A=$06, X=$01), nop #$EA on 65C02 (A=$01, X=$06) + bne @L9 + +; Check for 65816/65802 +@L6: xba ; .byte $EB, put $01 in B accu (nop on 65C02/65SC02) + dec a ; .byte $3A, A=$00 + xba ; .byte $EB, A=$01 if 65816/65802 and A=$00 if 65C02/65SC02 + inc a ; .byte $1A, A=$02 if 65816/65802 and A=$01 if 65C02/65SC02 + cmp #2 + beq @L9 + +; check for 65SC02 + + ldy $F7 + ldx #0 + stx $F7 + .byte $F7,$F7 ; nop nop on 65SC02, smb7 $F7 on 65C02 + ldx $F7 + sty $F7 + cpx #$00 + bne @L4 + lda #4 ; CPU_65SC02 constant - xba ; .byte $eb, put $01 in B accu - dec a ; .byte $3a, A=$00 if 65C02 - xba ; .byte $eb, get $01 back if 65816 - inc a ; .byte $1a, make $01/$02 - .byte $2c ; bit instruction to skip next command -@L8: lda #3 ; CPU_4510 constant @L9: ldx #0 ; Load high byte of word rts diff --git a/libsrc/common/interrupt.s b/libsrc/common/interrupt.s index 950d3d787..6bdbb5fe4 100644 --- a/libsrc/common/interrupt.s +++ b/libsrc/common/interrupt.s @@ -8,7 +8,7 @@ .export _set_irq, _reset_irq .interruptor clevel_irq, 1 ; Export as low priority IRQ handler - .import popax, __ZP_START__ + .import popax, __ZP_START__, jmpvec .include "zeropage.inc" @@ -84,6 +84,12 @@ zpsave: .res zpsavespace dex bpl @L2 + ; Save jmpvec + lda jmpvec+1 + pha + lda jmpvec+2 + pha + ; Set C level interrupt stack lda irqsp ldx irqsp+1 @@ -93,15 +99,21 @@ zpsave: .res zpsavespace ; Call C level interrupt request handler jsr irqvec - ; Copy back our zero page content + ; Mark interrupt handled / not handled + lsr + + ; Restore our zero page content ldx #.sizeof(::zpsave)-1 -@L3: ldy zpsave,x - sty <__ZP_START__,x +@L3: lda zpsave,x + sta <__ZP_START__,x dex bpl @L3 - ; Mark interrupt handled / not handled and return - lsr + ; Restore jmpvec and return + pla + sta jmpvec+2 + pla + sta jmpvec+1 rts .endproc diff --git a/libsrc/atari/tgi_colors.s b/libsrc/common/tgi_colors.s similarity index 100% rename from libsrc/atari/tgi_colors.s rename to libsrc/common/tgi_colors.s diff --git a/libsrc/apple2/toascii.s b/libsrc/common/toascii.s similarity index 87% rename from libsrc/apple2/toascii.s rename to libsrc/common/toascii.s index a3f946e64..5b1943aca 100644 --- a/libsrc/apple2/toascii.s +++ b/libsrc/common/toascii.s @@ -6,5 +6,5 @@ .export _toascii _toascii: - ldx #$00 + ldx #>$0000 rts diff --git a/libsrc/creativision/joy/creativision-stdjoy.s b/libsrc/creativision/joy/creativision-stdjoy.s index 9a5afc42b..5cf46c39f 100644 --- a/libsrc/creativision/joy/creativision-stdjoy.s +++ b/libsrc/creativision/joy/creativision-stdjoy.s @@ -33,7 +33,6 @@ .addr UNINSTALL .addr COUNT .addr READJOY - .addr 0 ; IRQ entry not used ; ------------------------------------------------------------------------ ; Constants diff --git a/libsrc/gamate/joy/gamate-stdjoy.s b/libsrc/gamate/joy/gamate-stdjoy.s index d10eb6f41..8f927cdf5 100644 --- a/libsrc/gamate/joy/gamate-stdjoy.s +++ b/libsrc/gamate/joy/gamate-stdjoy.s @@ -30,7 +30,6 @@ .addr UNINSTALL .addr COUNT .addr READJOY - .addr 0 ; IRQ entry unused ; ------------------------------------------------------------------------ ; Constants @@ -79,6 +78,7 @@ COUNT: READJOY: lda JOY_DATA + eor #$FF ldx #0 rts diff --git a/libsrc/gamate/joy_stat_stddrv.s b/libsrc/gamate/joy_stat_stddrv.s index 75016450a..94537b210 100644 --- a/libsrc/gamate/joy_stat_stddrv.s +++ b/libsrc/gamate/joy_stat_stddrv.s @@ -9,6 +9,4 @@ .export _joy_static_stddrv .import _gamate_stdjoy_joy -.rodata - _joy_static_stddrv := _gamate_stdjoy_joy diff --git a/libsrc/geos-cbm/disk/dio_cts.s b/libsrc/geos-cbm/disk/dio_cts.s index 8be343641..043e1f8d8 100644 --- a/libsrc/geos-cbm/disk/dio_cts.s +++ b/libsrc/geos-cbm/disk/dio_cts.s @@ -1,6 +1,6 @@ ; -; Maciej 'YTM/Elysium' Witkowiak -; 2.7.2001 +; 2001-07-02, Maciej 'YTM/Elysium' Witkowiak +; 2015-08-26, Greg King ; ; ; unsigned char __fastcall__ dio_phys_to_log (dhandle_t handle, @@ -59,7 +59,7 @@ _dio_phys_to_log: lda (ptr3),y tay lda driveType,y - and #%00000011 ; this is for RamDrive compatibility + and #%00001111 ; remove ramDisk flags cmp #DRV_1541 beq dio_cts1541 cmp #DRV_1571 @@ -67,7 +67,7 @@ _dio_phys_to_log: cmp #DRV_1581 beq dio_cts1581 - lda #DEV_NOT_FOUND ; unknown device + lda #INCOMPATIBLE ; unsupported device ldx #0 beq ret @@ -91,7 +91,7 @@ _inv_data: lda #INV_TRACK .byte $2c _inv_hand: - lda #INCOMPATIBLE + lda #DEV_NOT_FOUND ldx #0 beq ret diff --git a/libsrc/geos-cbm/disk/dio_openclose.s b/libsrc/geos-cbm/disk/dio_openclose.s index ec5aa8795..72e3e32e9 100644 --- a/libsrc/geos-cbm/disk/dio_openclose.s +++ b/libsrc/geos-cbm/disk/dio_openclose.s @@ -1,8 +1,8 @@ ; -; Maciej 'YTM/Elysium' Witkowiak +; 2001-07-02, Maciej 'YTM/Elysium' Witkowiak +; 2015-08-24, Greg King ; ; based on Atari version by Christian Groessler -; 2.7.2001 ; ; dhandle_t __fastcall__ dio_open (unsigned char device); ; unsigned char __fastcall__ dio_close (dhandle_t handle); @@ -27,11 +27,13 @@ sectsizetab: .code _dio_open: - pha + cmp #4 + bcs _inv_drive tax lda driveType,x ; check if there's a device beq _inv_drive txa + pha clc adc #8 ; normalize devnum sta curDevice diff --git a/libsrc/geos-cbm/disk/dio_read.s b/libsrc/geos-cbm/disk/dio_read.s index db46c9b69..ac19f9afa 100644 --- a/libsrc/geos-cbm/disk/dio_read.s +++ b/libsrc/geos-cbm/disk/dio_read.s @@ -1,6 +1,6 @@ ; -; Maciej 'YTM/Elysium' Witkowiak -; 2.7.2001 +; 2001-07-02, Maciej 'YTM/Elysium' Witkowiak +; 2015-08-27, Greg King ; ; this file provides the _dio_read function ; @@ -15,7 +15,9 @@ _dio_read: jsr dio_params + tay + bne err jsr ReadBlock stx __oserror txa - rts +err: rts diff --git a/libsrc/geos-cbm/disk/dio_stc.s b/libsrc/geos-cbm/disk/dio_stc.s index 586e3f3db..7398edb63 100644 --- a/libsrc/geos-cbm/disk/dio_stc.s +++ b/libsrc/geos-cbm/disk/dio_stc.s @@ -1,6 +1,6 @@ ; -; Maciej 'YTM/Elysium' Witkowiak -; 2.7.2001 +; 2001-07-02, Maciej 'YTM/Elysium' Witkowiak +; 2015-08-27, Greg King ; ; unsigned char __fastcall__ dio_log_to_phys (dhandle_t handle, ; unsigned *sectnum, /* input */ @@ -55,7 +55,7 @@ _dio_log_to_phys: lda (ptr3),y tay lda driveType,y - and #%00000011 ; this is for RamDrive compatibility + and #%00001111 ; remove ramDisk flags cmp #DRV_1541 beq dio_stc1541 cmp #DRV_1571 @@ -63,7 +63,7 @@ _dio_log_to_phys: cmp #DRV_1581 beq dio_stc1581 - lda #DEV_NOT_FOUND ; unknown device + lda #INCOMPATIBLE ; unsupported device ldx #0 beq _ret @@ -86,7 +86,7 @@ _inv_data: lda #INV_TRACK .byte $2c _inv_hand: - lda #INCOMPATIBLE + lda #DEV_NOT_FOUND ldx #0 beq _ret @@ -102,8 +102,8 @@ _loop41: bne _nxt lda tmp1 cmp sectab_1541_l+1,x - bcc _found -_nxt: inx +_nxt: bcc _found + inx cpx #35 bne _loop41 beq _inv_data @@ -124,12 +124,11 @@ dio_stc1571: ; - fall down to 1541 lda tmp2 cmp #>683 - bne _cnt71 + bne _if71 lda tmp1 cmp #<683 - bcc dio_stc1541 +_if71: bcc dio_stc1541 -_cnt71: lda tmp1 sec sbc #<683 @@ -138,6 +137,8 @@ _cnt71: sbc #>683 sta tmp2 jsr dio_stc1541 ; will fall through here + tay + bne _ret ; result beyond track 70 ldy #diopp_track lda (ptr1),y @@ -166,7 +167,7 @@ _sub81: lda tmp1 sbc #0 sta tmp2 inx - cpx #81 + cpx #80 bne _loop81 beq _inv_data diff --git a/libsrc/geos-cbm/disk/dio_write.s b/libsrc/geos-cbm/disk/dio_write.s index 14267803a..a5f747519 100644 --- a/libsrc/geos-cbm/disk/dio_write.s +++ b/libsrc/geos-cbm/disk/dio_write.s @@ -1,6 +1,6 @@ ; -; Maciej 'YTM/Elysium' Witkowiak -; 2.7.2001 +; 2001-07-02, Maciej 'YTM/Elysium' Witkowiak +; 2015-08-27, Greg King ; ; this file provides the _dio_write function ; @@ -15,5 +15,9 @@ _dio_write: jsr dio_params + tay + bne err jsr WriteBlock jmp setoserror + +err: rts diff --git a/libsrc/geos-cbm/disk/dio_writev.s b/libsrc/geos-cbm/disk/dio_writev.s index 7cb9b029f..9b36ed096 100644 --- a/libsrc/geos-cbm/disk/dio_writev.s +++ b/libsrc/geos-cbm/disk/dio_writev.s @@ -1,6 +1,6 @@ ; -; Maciej 'YTM/Elysium' Witkowiak -; 2.7.2001 +; 2001-07-02, Maciej 'YTM/Elysium' Witkowiak +; 2015-08-27, Greg King ; ; this file provides the _dio_write function ; @@ -15,7 +15,9 @@ _dio_write_verify: jsr dio_params + tay + bne err jsr VerWriteBlock stx __oserror txa - rts +err: rts diff --git a/libsrc/geos-cbm/geossym2.inc b/libsrc/geos-cbm/geossym2.inc index cdcbc24dc..02a2fd44b 100644 --- a/libsrc/geos-cbm/geossym2.inc +++ b/libsrc/geos-cbm/geossym2.inc @@ -4,8 +4,11 @@ ;4-2-99 bootName = $c006 +gatewayFlag = $c007 version = $c00f nationality = $c010 sysFlgCopy = $c012 c128Flag = $c013 -dateCopy = $c018 \ No newline at end of file +mp3Flag = $c014 +dateCopy = $c018 + diff --git a/libsrc/geos-cbm/system/get_ostype.s b/libsrc/geos-cbm/system/get_ostype.s index 492ce132d..6e6731952 100644 --- a/libsrc/geos-cbm/system/get_ostype.s +++ b/libsrc/geos-cbm/system/get_ostype.s @@ -3,8 +3,8 @@ ; ; 10.09.2001 ; -; Plus4 and GEOS 1.1 detection by -; Marco van den Heuvel, 2010-02-02 +; Plus4, Gateway, MP3 and GEOS 1.1 detection by +; Marco van den Heuvel, 2018-02-07 ; ; unsigned char get_ostype (void); @@ -26,11 +26,20 @@ _get_ostype: and #%11110000 cmp #$10 beq geos10 + cmp #$13 ; either 1.3 or 1.5 + beq geos13check + lda gatewayFlag + cmp #$41 + beq gateway + lda mp3Flag + cmp #$4d + beq megapatch3 lda c128Flag ; we're on at least 2.0 cmp #$18 beq geos_on_plus4 ora version rts +geos13: geos10: lda version rts @@ -40,6 +49,21 @@ geos11: geos_on_plus4: lda #$04 rts +gateway: + lda #$08 + ora c128Flag + rts +megapatch3: + lda #$03 + ora c128Flag + rts +geos13check: + lda mp3Flag + cmp #$03 + bne geos13 +geos15: + lda #$15 + rts _get_tv: jsr _get_ostype diff --git a/libsrc/geos-cbm/tgi/geos-tgi.s b/libsrc/geos-cbm/tgi/geos-tgi.s index 5a1af65e4..08927e6c1 100644 --- a/libsrc/geos-cbm/tgi/geos-tgi.s +++ b/libsrc/geos-cbm/tgi/geos-tgi.s @@ -74,7 +74,6 @@ aspect: .word $00D4 ; Aspect ratio (based on 4/3 display) .addr BAR .addr TEXTSTYLE .addr OUTTEXT - .addr 0 ; IRQ entry is unused ; ------------------------------------------------------------------------ ; Data. diff --git a/libsrc/geos-common/system/tgi_colors.s b/libsrc/geos-common/system/tgi_colors.s deleted file mode 100644 index 0d404294c..000000000 --- a/libsrc/geos-common/system/tgi_colors.s +++ /dev/null @@ -1,8 +0,0 @@ -; -; Target-specific black & white values, for use by the target-shared TGI kernel -; - - .include "tgi-kernel.inc" - -tgi_color_black = $00 -tgi_color_white = $01 diff --git a/libsrc/joystick/joy-kernel.s b/libsrc/joystick/joy-kernel.s index 0746709e9..c2d50c8d8 100644 --- a/libsrc/joystick/joy-kernel.s +++ b/libsrc/joystick/joy-kernel.s @@ -6,7 +6,6 @@ .import joy_libref .importzp ptr1 - .interruptor joy_irq ; Export as IRQ handler .include "joy-kernel.inc" .include "joy-error.inc" @@ -26,7 +25,6 @@ joy_install: jmp $0000 joy_uninstall: jmp $0000 joy_count: jmp $0000 joy_read: jmp $0000 -joy_irq: .byte $60, $00, $00 ; RTS plus two dummy bytes ; Driver header signature .rodata @@ -73,18 +71,7 @@ _joy_install: cpy #(JOY_HDR::JUMPTAB + .sizeof(JOY_HDR::JUMPTAB)) bne @L1 - jsr joy_install ; Call driver install routine - tay ; Test error code - bne @L2 ; Bail out if install had errors - -; Install the IRQ vector if the driver needs it. A/X contains the error code -; from joy_install, so don't use it. - - ldy joy_irq+2 ; Check high byte of IRQ vector - beq @L2 ; Jump if vector invalid - ldy #$4C ; JMP opcode - sty joy_irq ; Activate IRQ routine -@L2: rts + jmp joy_install ; Call driver install routine ; Driver signature invalid @@ -108,9 +95,6 @@ copy: lda (ptr1),y ; */ _joy_uninstall: - lda #$60 ; RTS opcode - sta joy_irq ; Disable IRQ entry point - jsr joy_uninstall ; Call the driver routine _joy_clear_ptr: ; External entry point diff --git a/libsrc/joystick/joy_read.s b/libsrc/joystick/joy_read.s index f76d9dfb7..151600aee 100644 --- a/libsrc/joystick/joy_read.s +++ b/libsrc/joystick/joy_read.s @@ -8,5 +8,3 @@ .include "joy-kernel.inc" _joy_read = joy_read ; Use driver entry - - diff --git a/libsrc/lynx/joy/lynx-stdjoy.s b/libsrc/lynx/joy/lynx-stdjoy.s index 2e91cc43b..c81a97dbf 100644 --- a/libsrc/lynx/joy/lynx-stdjoy.s +++ b/libsrc/lynx/joy/lynx-stdjoy.s @@ -37,7 +37,6 @@ .addr UNINSTALL .addr COUNT .addr READ - .addr 0 ; IRQ entry unused ; ------------------------------------------------------------------------ ; Constants diff --git a/libsrc/lynx/libref.s b/libsrc/lynx/libref.s index 62c78b8c5..0bda1e7e8 100644 --- a/libsrc/lynx/libref.s +++ b/libsrc/lynx/libref.s @@ -2,9 +2,8 @@ ; Oliver Schmidt, 2013-05-31 ; - .export joy_libref, ser_libref, tgi_libref + .export joy_libref, ser_libref .import _exit joy_libref := _exit ser_libref := _exit -tgi_libref := _exit diff --git a/libsrc/lynx/tgi/lynx-160-102-16.s b/libsrc/lynx/tgi/lynx-160-102-16.s index e6659631b..04bdaae04 100644 --- a/libsrc/lynx/tgi/lynx-160-102-16.s +++ b/libsrc/lynx/tgi/lynx-160-102-16.s @@ -29,7 +29,7 @@ .byte $74, $67, $69 ; "tgi" .byte TGI_API_VERSION ; TGI API version number - .addr $0000 ; Library reference +libref: .addr $0000 ; Library reference .word 160 ; X resolution .word 102 ; Y resolution .byte 16 ; Number of drawing colors @@ -64,7 +64,6 @@ .addr BAR .addr TEXTSTYLE .addr OUTTEXT - .addr IRQ ; ------------------------------------------------------------------------ @@ -164,6 +163,18 @@ INSTALL: stz BGINDEX stz DRAWPAGE stz SWAPREQUEST + lda libref + ldx libref+1 + sta ptr1 + stx ptr1+1 + ldy #1 + lda #<irq + sta (ptr1),y + iny + lda #>irq + sta (ptr1),y + lda #$4C ; Jump opcode + sta (ptr1) ; Activate IRQ routine rts @@ -175,6 +186,12 @@ INSTALL: ; UNINSTALL: + lda libref + ldx libref+1 + sta ptr1 + stx ptr1+1 + lda #$60 ; RTS opcode + sta (ptr1) ; Disable IRQ routine rts @@ -466,14 +483,10 @@ SETDRAWPAGE: stx DRAWPAGEH rts -; ------------------------------------------------------------------------ -; IRQ: VBL interrupt handler -; - -IRQ: +irq: lda INTSET ; Poll all pending interrupts and #VBL_INTERRUPT - beq IRQEND ; Exit if not a VBL interrupt + beq @L0 ; Exit if not a VBL interrupt lda SWAPREQUEST beq @L0 @@ -485,7 +498,6 @@ IRQ: jsr SETDRAWPAGE stz SWAPREQUEST @L0: -IRQEND: clc rts diff --git a/libsrc/lynx/tgi_irq.s b/libsrc/lynx/tgi_irq.s new file mode 100644 index 000000000..3968dc0b5 --- /dev/null +++ b/libsrc/lynx/tgi_irq.s @@ -0,0 +1,11 @@ +; +; Oliver Schmidt, 2018-02-02 +; + + .export tgi_libref + .interruptor tgi_irq ; Export as IRQ handler + + .data + +tgi_libref: +tgi_irq: .byte $60, $00, $00 ; RTS plus two dummy bytes diff --git a/libsrc/lynx/toascii.s b/libsrc/lynx/toascii.s deleted file mode 100644 index 2a2088688..000000000 --- a/libsrc/lynx/toascii.s +++ /dev/null @@ -1,16 +0,0 @@ -; -; unsigned char __fastcall__ toascii (unsigned char c); -; /* Convert a target specific character to ascii */ -; - -.export _toascii - -.proc _toascii - -; X must be zero on return - ldx #0 - -; Done! - rts - -.endproc diff --git a/libsrc/nes/joy/nes-stdjoy.s b/libsrc/nes/joy/nes-stdjoy.s index 3032e9330..63caf364b 100644 --- a/libsrc/nes/joy/nes-stdjoy.s +++ b/libsrc/nes/joy/nes-stdjoy.s @@ -35,7 +35,6 @@ .addr UNINSTALL .addr COUNT .addr READJOY - .addr 0 ; IRQ entry unused ; ------------------------------------------------------------------------ ; Constants diff --git a/libsrc/nes/tgi/nes-64-56-2.s b/libsrc/nes/tgi/nes-64-56-2.s index 70e23e119..e4dcb56ce 100644 --- a/libsrc/nes/tgi/nes-64-56-2.s +++ b/libsrc/nes/tgi/nes-64-56-2.s @@ -60,7 +60,6 @@ yres: .word 56 ; Max Y resolution .addr BAR .addr TEXTSTYLE .addr OUTTEXT - .addr 0 ; IRQ entry is unused ; ------------------------------------------------------------------------ ; Data. diff --git a/libsrc/nes/tgi_colors.s b/libsrc/nes/tgi_colors.s deleted file mode 100644 index 6ef3729b4..000000000 --- a/libsrc/nes/tgi_colors.s +++ /dev/null @@ -1,8 +0,0 @@ -; -; Target-specific black & white values for use by the target-shared TGI kernel -; - - .include "tgi-kernel.inc" - - .export tgi_color_black:zp = $00 - .export tgi_color_white:zp = $01 diff --git a/libsrc/none/crt0.s b/libsrc/none/crt0.s new file mode 100644 index 000000000..596fbcd46 --- /dev/null +++ b/libsrc/none/crt0.s @@ -0,0 +1,21 @@ + .export _exit + .export __STARTUP__ : absolute = 1 ; Mark as startup + .import zerobss, _main + .import initlib, donelib + .import __STACKSTART__ ; Linker generated + + .include "zeropage.inc" + + .segment "STARTUP" + + lda #<__STACKSTART__ + ldx #>__STACKSTART__ + sta sp + stx sp+1 + jsr zerobss + jsr initlib + jsr _main +_exit: pha + jsr donelib + pla + rts diff --git a/libsrc/none/ctype.s b/libsrc/none/ctype.s new file mode 100644 index 000000000..35968f982 --- /dev/null +++ b/libsrc/none/ctype.s @@ -0,0 +1,159 @@ +; +; Ullrich von Bassewitz, 2003-10-10 +; +; Character specification table. +; + + .include "ctype.inc" + +; The tables are readonly, put them into the rodata segment + +.rodata + +; The following 256 byte wide table specifies attributes for the isxxx type +; of functions. Doing it by a table means some overhead in space, but it +; has major advantages: +; +; * It is fast. If it weren't for the slow parameter passing of cc65, one +; could even define macros for the isxxx functions (this is usually +; done on other platforms). +; +; * It is highly portable. The only unportable part is the table itself, +; all real code goes into the common library. +; +; * We save some code in the isxxx functions. + + +__ctype: + .byte CT_CTRL ; 0/00 ___ctrl_@___ + .byte CT_CTRL ; 1/01 ___ctrl_A___ + .byte CT_CTRL ; 2/02 ___ctrl_B___ + .byte CT_CTRL ; 3/03 ___ctrl_C___ + .byte CT_CTRL ; 4/04 ___ctrl_D___ + .byte CT_CTRL ; 5/05 ___ctrl_E___ + .byte CT_CTRL ; 6/06 ___ctrl_F___ + .byte CT_CTRL ; 7/07 ___ctrl_G___ + .byte CT_CTRL ; 8/08 ___ctrl_H___ + .byte CT_CTRL | CT_OTHER_WS | CT_SPACE_TAB + ; 9/09 ___ctrl_I___ + .byte CT_CTRL | CT_OTHER_WS ; 10/0a ___ctrl_J___ + .byte CT_CTRL | CT_OTHER_WS ; 11/0b ___ctrl_K___ + .byte CT_CTRL | CT_OTHER_WS ; 12/0c ___ctrl_L___ + .byte CT_CTRL | CT_OTHER_WS ; 13/0d ___ctrl_M___ + .byte CT_CTRL ; 14/0e ___ctrl_N___ + .byte CT_CTRL ; 15/0f ___ctrl_O___ + .byte CT_CTRL ; 16/10 ___ctrl_P___ + .byte CT_CTRL ; 17/11 ___ctrl_Q___ + .byte CT_CTRL ; 18/12 ___ctrl_R___ + .byte CT_CTRL ; 19/13 ___ctrl_S___ + .byte CT_CTRL ; 20/14 ___ctrl_T___ + .byte CT_CTRL ; 21/15 ___ctrl_U___ + .byte CT_CTRL ; 22/16 ___ctrl_V___ + .byte CT_CTRL ; 23/17 ___ctrl_W___ + .byte CT_CTRL ; 24/18 ___ctrl_X___ + .byte CT_CTRL ; 25/19 ___ctrl_Y___ + .byte CT_CTRL ; 26/1a ___ctrl_Z___ + .byte CT_CTRL ; 27/1b ___ctrl_[___ + .byte CT_CTRL ; 28/1c ___ctrl_\___ + .byte CT_CTRL ; 29/1d ___ctrl_]___ + .byte CT_CTRL ; 30/1e ___ctrl_^___ + .byte CT_CTRL ; 31/1f ___ctrl_____ + .byte CT_SPACE | CT_SPACE_TAB ; 32/20 ___SPACE___ + .byte CT_NONE ; 33/21 _____!_____ + .byte CT_NONE ; 34/22 _____"_____ + .byte CT_NONE ; 35/23 _____#_____ + .byte CT_NONE ; 36/24 _____$_____ + .byte CT_NONE ; 37/25 _____%_____ + .byte CT_NONE ; 38/26 _____&_____ + .byte CT_NONE ; 39/27 _____'_____ + .byte CT_NONE ; 40/28 _____(_____ + .byte CT_NONE ; 41/29 _____)_____ + .byte CT_NONE ; 42/2a _____*_____ + .byte CT_NONE ; 43/2b _____+_____ + .byte CT_NONE ; 44/2c _____,_____ + .byte CT_NONE ; 45/2d _____-_____ + .byte CT_NONE ; 46/2e _____._____ + .byte CT_NONE ; 47/2f _____/_____ + .byte CT_DIGIT | CT_XDIGIT ; 48/30 _____0_____ + .byte CT_DIGIT | CT_XDIGIT ; 49/31 _____1_____ + .byte CT_DIGIT | CT_XDIGIT ; 50/32 _____2_____ + .byte CT_DIGIT | CT_XDIGIT ; 51/33 _____3_____ + .byte CT_DIGIT | CT_XDIGIT ; 52/34 _____4_____ + .byte CT_DIGIT | CT_XDIGIT ; 53/35 _____5_____ + .byte CT_DIGIT | CT_XDIGIT ; 54/36 _____6_____ + .byte CT_DIGIT | CT_XDIGIT ; 55/37 _____7_____ + .byte CT_DIGIT | CT_XDIGIT ; 56/38 _____8_____ + .byte CT_DIGIT | CT_XDIGIT ; 57/39 _____9_____ + .byte CT_NONE ; 58/3a _____:_____ + .byte CT_NONE ; 59/3b _____;_____ + .byte CT_NONE ; 60/3c _____<_____ + .byte CT_NONE ; 61/3d _____=_____ + .byte CT_NONE ; 62/3e _____>_____ + .byte CT_NONE ; 63/3f _____?_____ + + .byte CT_NONE ; 64/40 _____@_____ + .byte CT_UPPER | CT_XDIGIT ; 65/41 _____A_____ + .byte CT_UPPER | CT_XDIGIT ; 66/42 _____B_____ + .byte CT_UPPER | CT_XDIGIT ; 67/43 _____C_____ + .byte CT_UPPER | CT_XDIGIT ; 68/44 _____D_____ + .byte CT_UPPER | CT_XDIGIT ; 69/45 _____E_____ + .byte CT_UPPER | CT_XDIGIT ; 70/46 _____F_____ + .byte CT_UPPER ; 71/47 _____G_____ + .byte CT_UPPER ; 72/48 _____H_____ + .byte CT_UPPER ; 73/49 _____I_____ + .byte CT_UPPER ; 74/4a _____J_____ + .byte CT_UPPER ; 75/4b _____K_____ + .byte CT_UPPER ; 76/4c _____L_____ + .byte CT_UPPER ; 77/4d _____M_____ + .byte CT_UPPER ; 78/4e _____N_____ + .byte CT_UPPER ; 79/4f _____O_____ + .byte CT_UPPER ; 80/50 _____P_____ + .byte CT_UPPER ; 81/51 _____Q_____ + .byte CT_UPPER ; 82/52 _____R_____ + .byte CT_UPPER ; 83/53 _____S_____ + .byte CT_UPPER ; 84/54 _____T_____ + .byte CT_UPPER ; 85/55 _____U_____ + .byte CT_UPPER ; 86/56 _____V_____ + .byte CT_UPPER ; 87/57 _____W_____ + .byte CT_UPPER ; 88/58 _____X_____ + .byte CT_UPPER ; 89/59 _____Y_____ + .byte CT_UPPER ; 90/5a _____Z_____ + .byte CT_NONE ; 91/5b _____[_____ + .byte CT_NONE ; 92/5c _____\_____ + .byte CT_NONE ; 93/5d _____]_____ + .byte CT_NONE ; 94/5e _____^_____ + .byte CT_NONE ; 95/5f _UNDERLINE_ + .byte CT_NONE ; 96/60 ___grave___ + .byte CT_LOWER | CT_XDIGIT ; 97/61 _____a_____ + .byte CT_LOWER | CT_XDIGIT ; 98/62 _____b_____ + .byte CT_LOWER | CT_XDIGIT ; 99/63 _____c_____ + .byte CT_LOWER | CT_XDIGIT ; 100/64 _____d_____ + .byte CT_LOWER | CT_XDIGIT ; 101/65 _____e_____ + .byte CT_LOWER | CT_XDIGIT ; 102/66 _____f_____ + .byte CT_LOWER ; 103/67 _____g_____ + .byte CT_LOWER ; 104/68 _____h_____ + .byte CT_LOWER ; 105/69 _____i_____ + .byte CT_LOWER ; 106/6a _____j_____ + .byte CT_LOWER ; 107/6b _____k_____ + .byte CT_LOWER ; 108/6c _____l_____ + .byte CT_LOWER ; 109/6d _____m_____ + .byte CT_LOWER ; 110/6e _____n_____ + .byte CT_LOWER ; 111/6f _____o_____ + .byte CT_LOWER ; 112/70 _____p_____ + .byte CT_LOWER ; 113/71 _____q_____ + .byte CT_LOWER ; 114/72 _____r_____ + .byte CT_LOWER ; 115/73 _____s_____ + .byte CT_LOWER ; 116/74 _____t_____ + .byte CT_LOWER ; 117/75 _____u_____ + .byte CT_LOWER ; 118/76 _____v_____ + .byte CT_LOWER ; 119/77 _____w_____ + .byte CT_LOWER ; 120/78 _____x_____ + .byte CT_LOWER ; 121/79 _____y_____ + .byte CT_LOWER ; 122/7a _____z_____ + .byte CT_NONE ; 123/7b _____{_____ + .byte CT_NONE ; 124/7c _____|_____ + .byte CT_NONE ; 125/7d _____}_____ + .byte CT_NONE ; 126/7e _____~_____ + .byte CT_OTHER_WS ; 127/7f ____DEL____ + + .res 128, CT_NONE ; 128-255 diff --git a/libsrc/osic1p/ctype.s b/libsrc/osic1p/ctype.s index fa901c189..35968f982 100644 --- a/libsrc/osic1p/ctype.s +++ b/libsrc/osic1p/ctype.s @@ -1,289 +1,159 @@ ; +; Ullrich von Bassewitz, 2003-10-10 +; ; Character specification table. ; -; Ullrich von Bassewitz, 02.06.1998 -; 2003-05-02, Greg King -; -; Copied from cbm/ctype.s -; The following 256-byte-wide table specifies attributes for the isxxx type -; of functions. Doing it by a table means some overhead in space, but it + .include "ctype.inc" + +; The tables are readonly, put them into the rodata segment + +.rodata + +; The following 256 byte wide table specifies attributes for the isxxx type +; of functions. Doing it by a table means some overhead in space, but it ; has major advantages: ; -; * It is fast. If it weren't for the slow parameter-passing of cc65, -; one even could define C-language macroes for the isxxx functions -; (as it usually is done, on other platforms). +; * It is fast. If it weren't for the slow parameter passing of cc65, one +; could even define macros for the isxxx functions (this is usually +; done on other platforms). ; -; * It is highly portable. The only unportable part is the table itself; +; * It is highly portable. The only unportable part is the table itself, ; all real code goes into the common library. ; ; * We save some code in the isxxx functions. -; This table is taken from Craig S. Bruce's technical docs. for the ACE OS. - - .include "ctype.inc" - -; The table is read-only, put it into the RODATA segment. - - .rodata __ctype: - .byte CT_CTRL ; 0/00 ___rvs_@___ - .byte CT_CTRL ; 1/01 ___rvs_a___ - .byte CT_CTRL ; 2/02 ___rvs_b___ - .byte CT_CTRL ; 3/03 ___rvs_c___ - .byte CT_CTRL ; 4/04 ___rvs_d___ - .byte CT_CTRL ; 5/05 ___rvs_e___ - .byte CT_CTRL ; 6/06 ___rvs_f___ - .byte CT_CTRL ; 7/07 _BEL/rvs_g_ - .byte CT_CTRL ; 8/08 ___rvs_h___ - .byte CT_CTRL | CT_OTHER_WS | CT_SPACE_TAB ; 9/09 _TAB/rvs_i_ - .byte CT_CTRL | CT_OTHER_WS ; 10/0a _BOL/rvs_j_ - .byte CT_CTRL ; 11/0b ___rvs_k___ - .byte CT_CTRL ; 12/0c ___rvs_l___ - .byte CT_CTRL | CT_OTHER_WS ; 13/0d _CR_/rvs_m_ - .byte CT_CTRL ; 14/0e ___rvs_n___ - .byte CT_CTRL ; 15/0f ___rvs_o___ - .byte CT_CTRL ; 16/10 ___rvs_p___ - .byte CT_CTRL | CT_OTHER_WS ; 17/11 _VT_/rvs_q_ - .byte CT_CTRL ; 18/12 ___rvs_r___ - .byte CT_CTRL | CT_OTHER_WS ; 19/13 HOME/rvs_s_ - .byte CT_CTRL | CT_OTHER_WS ; 20/14 _BS_/rvs_t_ - .byte CT_CTRL ; 21/15 ___rvs_u___ - .byte CT_CTRL ; 22/16 ___rvs_v___ - .byte CT_CTRL ; 23/17 ___rvs_w___ - .byte CT_CTRL ; 24/18 ___rvs_x___ - .byte CT_CTRL ; 25/19 ___rvs_y___ - .byte CT_CTRL ; 26/1a ___rvs_z___ - .byte CT_CTRL ; 27/1b ___rvs_[___ - .byte CT_CTRL ; 28/1c ___rvs_\___ - .byte CT_CTRL | CT_OTHER_WS ; 29/1d cursr-right - .byte CT_CTRL ; 30/1e ___rvs_^___ - .byte CT_CTRL ; 31/1f _rvs_under_ - .byte CT_SPACE | CT_SPACE_TAB ; 32/20 ___SPACE___ - .byte $00 ; 33/21 _____!_____ - .byte $00 ; 34/22 _____"_____ - .byte $00 ; 35/23 _____#_____ - .byte $00 ; 36/24 _____$_____ - .byte $00 ; 37/25 _____%_____ - .byte $00 ; 38/26 _____&_____ - .byte $00 ; 39/27 _____'_____ - .byte $00 ; 40/28 _____(_____ - .byte $00 ; 41/29 _____)_____ - .byte $00 ; 42/2a _____*_____ - .byte $00 ; 43/2b _____+_____ - .byte $00 ; 44/2c _____,_____ - .byte $00 ; 45/2d _____-_____ - .byte $00 ; 46/2e _____._____ - .byte $00 ; 47/2f _____/_____ - .byte CT_DIGIT | CT_XDIGIT ; 48/30 _____0_____ - .byte CT_DIGIT | CT_XDIGIT ; 49/31 _____1_____ - .byte CT_DIGIT | CT_XDIGIT ; 50/32 _____2_____ - .byte CT_DIGIT | CT_XDIGIT ; 51/33 _____3_____ - .byte CT_DIGIT | CT_XDIGIT ; 52/34 _____4_____ - .byte CT_DIGIT | CT_XDIGIT ; 53/35 _____5_____ - .byte CT_DIGIT | CT_XDIGIT ; 54/36 _____6_____ - .byte CT_DIGIT | CT_XDIGIT ; 55/37 _____7_____ - .byte CT_DIGIT | CT_XDIGIT ; 56/38 _____8_____ - .byte CT_DIGIT | CT_XDIGIT ; 57/39 _____9_____ - .byte $00 ; 58/3a _____:_____ - .byte $00 ; 59/3b _____;_____ - .byte $00 ; 60/3c _____<_____ - .byte $00 ; 61/3d _____=_____ - .byte $00 ; 62/3e _____>_____ - .byte $00 ; 63/3f _____?_____ + .byte CT_CTRL ; 0/00 ___ctrl_@___ + .byte CT_CTRL ; 1/01 ___ctrl_A___ + .byte CT_CTRL ; 2/02 ___ctrl_B___ + .byte CT_CTRL ; 3/03 ___ctrl_C___ + .byte CT_CTRL ; 4/04 ___ctrl_D___ + .byte CT_CTRL ; 5/05 ___ctrl_E___ + .byte CT_CTRL ; 6/06 ___ctrl_F___ + .byte CT_CTRL ; 7/07 ___ctrl_G___ + .byte CT_CTRL ; 8/08 ___ctrl_H___ + .byte CT_CTRL | CT_OTHER_WS | CT_SPACE_TAB + ; 9/09 ___ctrl_I___ + .byte CT_CTRL | CT_OTHER_WS ; 10/0a ___ctrl_J___ + .byte CT_CTRL | CT_OTHER_WS ; 11/0b ___ctrl_K___ + .byte CT_CTRL | CT_OTHER_WS ; 12/0c ___ctrl_L___ + .byte CT_CTRL | CT_OTHER_WS ; 13/0d ___ctrl_M___ + .byte CT_CTRL ; 14/0e ___ctrl_N___ + .byte CT_CTRL ; 15/0f ___ctrl_O___ + .byte CT_CTRL ; 16/10 ___ctrl_P___ + .byte CT_CTRL ; 17/11 ___ctrl_Q___ + .byte CT_CTRL ; 18/12 ___ctrl_R___ + .byte CT_CTRL ; 19/13 ___ctrl_S___ + .byte CT_CTRL ; 20/14 ___ctrl_T___ + .byte CT_CTRL ; 21/15 ___ctrl_U___ + .byte CT_CTRL ; 22/16 ___ctrl_V___ + .byte CT_CTRL ; 23/17 ___ctrl_W___ + .byte CT_CTRL ; 24/18 ___ctrl_X___ + .byte CT_CTRL ; 25/19 ___ctrl_Y___ + .byte CT_CTRL ; 26/1a ___ctrl_Z___ + .byte CT_CTRL ; 27/1b ___ctrl_[___ + .byte CT_CTRL ; 28/1c ___ctrl_\___ + .byte CT_CTRL ; 29/1d ___ctrl_]___ + .byte CT_CTRL ; 30/1e ___ctrl_^___ + .byte CT_CTRL ; 31/1f ___ctrl_____ + .byte CT_SPACE | CT_SPACE_TAB ; 32/20 ___SPACE___ + .byte CT_NONE ; 33/21 _____!_____ + .byte CT_NONE ; 34/22 _____"_____ + .byte CT_NONE ; 35/23 _____#_____ + .byte CT_NONE ; 36/24 _____$_____ + .byte CT_NONE ; 37/25 _____%_____ + .byte CT_NONE ; 38/26 _____&_____ + .byte CT_NONE ; 39/27 _____'_____ + .byte CT_NONE ; 40/28 _____(_____ + .byte CT_NONE ; 41/29 _____)_____ + .byte CT_NONE ; 42/2a _____*_____ + .byte CT_NONE ; 43/2b _____+_____ + .byte CT_NONE ; 44/2c _____,_____ + .byte CT_NONE ; 45/2d _____-_____ + .byte CT_NONE ; 46/2e _____._____ + .byte CT_NONE ; 47/2f _____/_____ + .byte CT_DIGIT | CT_XDIGIT ; 48/30 _____0_____ + .byte CT_DIGIT | CT_XDIGIT ; 49/31 _____1_____ + .byte CT_DIGIT | CT_XDIGIT ; 50/32 _____2_____ + .byte CT_DIGIT | CT_XDIGIT ; 51/33 _____3_____ + .byte CT_DIGIT | CT_XDIGIT ; 52/34 _____4_____ + .byte CT_DIGIT | CT_XDIGIT ; 53/35 _____5_____ + .byte CT_DIGIT | CT_XDIGIT ; 54/36 _____6_____ + .byte CT_DIGIT | CT_XDIGIT ; 55/37 _____7_____ + .byte CT_DIGIT | CT_XDIGIT ; 56/38 _____8_____ + .byte CT_DIGIT | CT_XDIGIT ; 57/39 _____9_____ + .byte CT_NONE ; 58/3a _____:_____ + .byte CT_NONE ; 59/3b _____;_____ + .byte CT_NONE ; 60/3c _____<_____ + .byte CT_NONE ; 61/3d _____=_____ + .byte CT_NONE ; 62/3e _____>_____ + .byte CT_NONE ; 63/3f _____?_____ - .byte $00 ; 64/40 _____@_____ - .byte CT_LOWER | CT_XDIGIT ; 65/41 _____a_____ - .byte CT_LOWER | CT_XDIGIT ; 66/42 _____b_____ - .byte CT_LOWER | CT_XDIGIT ; 67/43 _____c_____ - .byte CT_LOWER | CT_XDIGIT ; 68/44 _____d_____ - .byte CT_LOWER | CT_XDIGIT ; 69/45 _____e_____ - .byte CT_LOWER | CT_XDIGIT ; 70/46 _____f_____ - .byte CT_LOWER ; 71/47 _____g_____ - .byte CT_LOWER ; 72/48 _____h_____ - .byte CT_LOWER ; 73/49 _____i_____ - .byte CT_LOWER ; 74/4a _____j_____ - .byte CT_LOWER ; 75/4b _____k_____ - .byte CT_LOWER ; 76/4c _____l_____ - .byte CT_LOWER ; 77/4d _____m_____ - .byte CT_LOWER ; 78/4e _____n_____ - .byte CT_LOWER ; 79/4f _____o_____ - .byte CT_LOWER ; 80/50 _____p_____ - .byte CT_LOWER ; 81/51 _____q_____ - .byte CT_LOWER ; 82/52 _____r_____ - .byte CT_LOWER ; 83/53 _____s_____ - .byte CT_LOWER ; 84/54 _____t_____ - .byte CT_LOWER ; 85/55 _____u_____ - .byte CT_LOWER ; 86/56 _____v_____ - .byte CT_LOWER ; 87/57 _____w_____ - .byte CT_LOWER ; 88/58 _____x_____ - .byte CT_LOWER ; 89/59 _____y_____ - .byte CT_LOWER ; 90/5a _____z_____ - .byte $00 ; 91/5b _____[_____ - .byte $00 ; 92/5c _____\_____ - .byte $00 ; 93/5d _____]_____ - .byte $00 ; 94/5e _____^_____ - .byte $00 ; 95/5f _UNDERLINE_ - .byte $00 ; 96/60 _A`_grave__ - .byte $00 ; 97/61 _A'_acute__ - .byte $00 ; 98/62 _A^_circum_ - .byte $00 ; 99/63 _A~_tilde__ - .byte $00 ; 100/64 _A"_dieres_ - .byte $00 ; 101/65 _A__ring___ - .byte $00 ; 102/66 _AE________ - .byte $00 ; 103/67 _C,cedilla_ - .byte $00 ; 104/68 _E`_grave__ - .byte $00 ; 105/69 _E'_acute__ - .byte $00 ; 106/6a _E^_circum_ - .byte $00 ; 107/6b _E"_dieres_ - .byte $00 ; 108/6c _I`_grave__ - .byte $00 ; 109/6d _I'_acute__ - .byte $00 ; 110/6e _I^_circum_ - .byte $00 ; 111/6f _I"_dieres_ - .byte $00 ; 112/70 _D-_Eth_lr_ - .byte $00 ; 113/71 _N~_tilde__ - .byte $00 ; 114/72 _O`_grave__ - .byte $00 ; 115/73 _O'_acute__ - .byte $00 ; 116/74 _O^_circum_ - .byte $00 ; 117/75 _O~_tilde__ - .byte $00 ; 118/76 _O"_dieres_ - .byte $00 ; 119/77 __multiply_ - .byte $00 ; 120/78 _O/_slash__ - .byte $00 ; 121/79 _U`_grave__ - .byte $00 ; 122/7a _U'_acute__ - .byte $00 ; 123/7b _U^_circum_ - .byte $00 ; 124/7c _U"_dieres_ - .byte $00 ; 125/7d _Y'_acute__ - .byte $00 ; 126/7e _cap_thorn_ - .byte $00 ; 127/7f _Es-sed_B__ + .byte CT_NONE ; 64/40 _____@_____ + .byte CT_UPPER | CT_XDIGIT ; 65/41 _____A_____ + .byte CT_UPPER | CT_XDIGIT ; 66/42 _____B_____ + .byte CT_UPPER | CT_XDIGIT ; 67/43 _____C_____ + .byte CT_UPPER | CT_XDIGIT ; 68/44 _____D_____ + .byte CT_UPPER | CT_XDIGIT ; 69/45 _____E_____ + .byte CT_UPPER | CT_XDIGIT ; 70/46 _____F_____ + .byte CT_UPPER ; 71/47 _____G_____ + .byte CT_UPPER ; 72/48 _____H_____ + .byte CT_UPPER ; 73/49 _____I_____ + .byte CT_UPPER ; 74/4a _____J_____ + .byte CT_UPPER ; 75/4b _____K_____ + .byte CT_UPPER ; 76/4c _____L_____ + .byte CT_UPPER ; 77/4d _____M_____ + .byte CT_UPPER ; 78/4e _____N_____ + .byte CT_UPPER ; 79/4f _____O_____ + .byte CT_UPPER ; 80/50 _____P_____ + .byte CT_UPPER ; 81/51 _____Q_____ + .byte CT_UPPER ; 82/52 _____R_____ + .byte CT_UPPER ; 83/53 _____S_____ + .byte CT_UPPER ; 84/54 _____T_____ + .byte CT_UPPER ; 85/55 _____U_____ + .byte CT_UPPER ; 86/56 _____V_____ + .byte CT_UPPER ; 87/57 _____W_____ + .byte CT_UPPER ; 88/58 _____X_____ + .byte CT_UPPER ; 89/59 _____Y_____ + .byte CT_UPPER ; 90/5a _____Z_____ + .byte CT_NONE ; 91/5b _____[_____ + .byte CT_NONE ; 92/5c _____\_____ + .byte CT_NONE ; 93/5d _____]_____ + .byte CT_NONE ; 94/5e _____^_____ + .byte CT_NONE ; 95/5f _UNDERLINE_ + .byte CT_NONE ; 96/60 ___grave___ + .byte CT_LOWER | CT_XDIGIT ; 97/61 _____a_____ + .byte CT_LOWER | CT_XDIGIT ; 98/62 _____b_____ + .byte CT_LOWER | CT_XDIGIT ; 99/63 _____c_____ + .byte CT_LOWER | CT_XDIGIT ; 100/64 _____d_____ + .byte CT_LOWER | CT_XDIGIT ; 101/65 _____e_____ + .byte CT_LOWER | CT_XDIGIT ; 102/66 _____f_____ + .byte CT_LOWER ; 103/67 _____g_____ + .byte CT_LOWER ; 104/68 _____h_____ + .byte CT_LOWER ; 105/69 _____i_____ + .byte CT_LOWER ; 106/6a _____j_____ + .byte CT_LOWER ; 107/6b _____k_____ + .byte CT_LOWER ; 108/6c _____l_____ + .byte CT_LOWER ; 109/6d _____m_____ + .byte CT_LOWER ; 110/6e _____n_____ + .byte CT_LOWER ; 111/6f _____o_____ + .byte CT_LOWER ; 112/70 _____p_____ + .byte CT_LOWER ; 113/71 _____q_____ + .byte CT_LOWER ; 114/72 _____r_____ + .byte CT_LOWER ; 115/73 _____s_____ + .byte CT_LOWER ; 116/74 _____t_____ + .byte CT_LOWER ; 117/75 _____u_____ + .byte CT_LOWER ; 118/76 _____v_____ + .byte CT_LOWER ; 119/77 _____w_____ + .byte CT_LOWER ; 120/78 _____x_____ + .byte CT_LOWER ; 121/79 _____y_____ + .byte CT_LOWER ; 122/7a _____z_____ + .byte CT_NONE ; 123/7b _____{_____ + .byte CT_NONE ; 124/7c _____|_____ + .byte CT_NONE ; 125/7d _____}_____ + .byte CT_NONE ; 126/7e _____~_____ + .byte CT_OTHER_WS ; 127/7f ____DEL____ - .byte CT_CTRL ; 128/80 __bullet___ - .byte CT_CTRL ; 129/81 __v_line___ - .byte CT_CTRL ; 130/82 __h_line___ - .byte CT_CTRL ; 131/83 ___cross___ - .byte CT_CTRL ; 132/84 _tl_corner_ - .byte CT_CTRL ; 133/85 _tr_corner_ - .byte CT_CTRL ; 134/86 _bl_corner_ - .byte CT_CTRL ; 135/87 _br_corner_ - .byte CT_CTRL ; 136/88 ___l_tee___ - .byte CT_CTRL ; 137/89 ___r_tee___ - .byte CT_CTRL ; 138/8a ___t_tee___ - .byte CT_CTRL ; 139/8b ___b_tee___ - .byte CT_CTRL ; 140/8c ___heart___ - .byte CT_CTRL | CT_OTHER_WS ; 141/8d _CR/diamond - .byte CT_CTRL ; 142/8e ___club____ - .byte CT_CTRL ; 143/8f ___spade___ - .byte CT_CTRL ; 144/90 _s_circle__ - .byte CT_CTRL | CT_OTHER_WS ; 145/91 _cursor-up_ - .byte CT_CTRL ; 146/92 ___pound___ - .byte CT_CTRL | CT_OTHER_WS ; 147/93 _CLS/check_ - .byte CT_CTRL | CT_OTHER_WS ; 148/94 __INSert___ - .byte CT_CTRL ; 149/95 ____+/-____ - .byte CT_CTRL ; 150/96 __divide___ - .byte CT_CTRL ; 151/97 __degree___ - .byte CT_CTRL ; 152/98 _c_checker_ - .byte CT_CTRL ; 153/99 _f_checker_ - .byte CT_CTRL ; 154/9a _solid_sq__ - .byte CT_CTRL ; 155/9b __cr_char__ - .byte CT_CTRL ; 156/9c _up_arrow__ - .byte CT_CTRL | CT_OTHER_WS ; 157/9d cursor-left - .byte CT_CTRL ; 158/9e _left_arro_ - .byte CT_CTRL ; 159/9f _right_arr_ - .byte CT_SPACE | CT_SPACE_TAB ; 160/a0 _req space_ - .byte $00 ; 161/a1 _!_invertd_ - .byte $00 ; 162/a2 ___cent____ - .byte $00 ; 163/a3 ___pound___ - .byte $00 ; 164/a4 __currency_ - .byte $00 ; 165/a5 ____yen____ - .byte $00 ; 166/a6 _|_broken__ - .byte $00 ; 167/a7 __section__ - .byte $00 ; 168/a8 __umulaut__ - .byte $00 ; 169/a9 _copyright_ - .byte $00 ; 170/aa __fem_ord__ - .byte $00 ; 171/ab _l_ang_quo_ - .byte $00 ; 172/ac ____not____ - .byte $00 ; 173/ad _syl_hyphn_ - .byte $00 ; 174/ae _registerd_ - .byte $00 ; 175/af _overline__ - .byte $00 ; 176/b0 __degrees__ - .byte $00 ; 177/b1 ____+/-____ - .byte $00 ; 178/b2 _2_supersc_ - .byte $00 ; 179/b3 _3_supersc_ - .byte $00 ; 180/b4 ___acute___ - .byte $00 ; 181/b5 ____mu_____ - .byte $00 ; 182/b6 _paragraph_ - .byte $00 ; 183/b7 __mid_dot__ - .byte $00 ; 184/b8 __cedilla__ - .byte $00 ; 185/b9 _1_supersc_ - .byte $00 ; 186/ba __mas_ord__ - .byte $00 ; 187/bb _r_ang_quo_ - .byte $00 ; 188/bc ____1/4____ - .byte $00 ; 189/bd ____1/2____ - .byte $00 ; 190/be ____3/4____ - .byte $00 ; 191/bf _?_invertd_ - - .byte $00 ; 192/c0 _____`_____ - .byte CT_UPPER | CT_XDIGIT ; 193/c1 _____A_____ - .byte CT_UPPER | CT_XDIGIT ; 194/c2 _____B_____ - .byte CT_UPPER | CT_XDIGIT ; 195/c3 _____C_____ - .byte CT_UPPER | CT_XDIGIT ; 196/c4 _____D_____ - .byte CT_UPPER | CT_XDIGIT ; 197/c5 _____E_____ - .byte CT_UPPER | CT_XDIGIT ; 198/c6 _____F_____ - .byte CT_UPPER ; 199/c7 _____G_____ - .byte CT_UPPER ; 200/c8 _____H_____ - .byte CT_UPPER ; 201/c9 _____I_____ - .byte CT_UPPER ; 202/ca _____J_____ - .byte CT_UPPER ; 203/cb _____K_____ - .byte CT_UPPER ; 204/cc _____L_____ - .byte CT_UPPER ; 205/cd _____M_____ - .byte CT_UPPER ; 206/ce _____N_____ - .byte CT_UPPER ; 207/cf _____O_____ - .byte CT_UPPER ; 208/d0 _____P_____ - .byte CT_UPPER ; 209/d1 _____Q_____ - .byte CT_UPPER ; 210/d2 _____R_____ - .byte CT_UPPER ; 211/d3 _____S_____ - .byte CT_UPPER ; 212/d4 _____T_____ - .byte CT_UPPER ; 213/d5 _____U_____ - .byte CT_UPPER ; 214/d6 _____V_____ - .byte CT_UPPER ; 215/d7 _____W_____ - .byte CT_UPPER ; 216/d8 _____X_____ - .byte CT_UPPER ; 217/d9 _____Y_____ - .byte CT_UPPER ; 218/da _____Z_____ - .byte $00 ; 219/db _____{_____ - .byte $00 ; 220/dc _____|_____ - .byte $00 ; 221/dd _____}_____ - .byte $00 ; 222/de _____~_____ - .byte $00 ; 223/df ___HOUSE___ - .byte $00 ; 224/e0 _a`_grave__ - .byte $00 ; 225/e1 _a'_acute__ - .byte $00 ; 226/e2 _a^_circum_ - .byte $00 ; 227/e3 _a~_tilde__ - .byte $00 ; 228/e4 _a"_dieres_ - .byte $00 ; 229/e5 _a__ring___ - .byte $00 ; 230/e6 _ae________ - .byte $00 ; 231/e7 _c,cedilla_ - .byte $00 ; 232/e8 _e`_grave__ - .byte $00 ; 233/e9 _e'_acute__ - .byte $00 ; 234/ea _e^_circum_ - .byte $00 ; 235/eb _e"_dieres_ - .byte $00 ; 236/ec _i`_grave__ - .byte $00 ; 237/ed _i'_acute__ - .byte $00 ; 238/ee _i^_circum_ - .byte $00 ; 239/ef _i"_dieres_ - .byte $00 ; 240/f0 _o^x_Eth_s_ - .byte $00 ; 241/f1 _n~_tilda__ - .byte $00 ; 242/f2 _o`_grave__ - .byte $00 ; 243/f3 _o'_acute__ - .byte $00 ; 244/f4 _o^_circum_ - .byte $00 ; 245/f5 _o~_tilde__ - .byte $00 ; 246/f6 _o"_dieres_ - .byte $00 ; 247/f7 __divide___ - .byte $00 ; 248/f8 _o/_slash__ - .byte $00 ; 249/f9 _u`_grave__ - .byte $00 ; 250/fa _u'_acute__ - .byte $00 ; 251/fb _u^_circum_ - .byte $00 ; 252/fc _u"_dieres_ - .byte $00 ; 253/fd _y'_acute__ - .byte $00 ; 254/fe _sm_thorn__ - .byte $00 ; 255/ff _y"_dieres_ + .res 128, CT_NONE ; 128-255 diff --git a/libsrc/pce/call.s b/libsrc/pce/call.s new file mode 100644 index 000000000..f99879866 --- /dev/null +++ b/libsrc/pce/call.s @@ -0,0 +1,16 @@ +; +; CC65 runtime: call function via pointer in ax +; +; 1998-08-06, Ullrich von Bassewitz +; 2018-02-28, Greg King +; + + .export callax + .importzp ptr1 + +callax: sta ptr1 + stx ptr1+1 + +; The PC-Engine puts the zero-page at $2000. + + jmp (ptr1 + $2000) ; go there diff --git a/libsrc/pce/callptr4.s b/libsrc/pce/callptr4.s new file mode 100644 index 000000000..7829cdb8e --- /dev/null +++ b/libsrc/pce/callptr4.s @@ -0,0 +1,14 @@ +; +; CC65 runtime: call function via pointer in ptr4 +; +; 2018-02-28, Greg King +; + + .export callptr4 + .importzp ptr4 + +callptr4: + +; The PC-Engine puts the zero-page at $2000. + + jmp (ptr4 + $2000) diff --git a/libsrc/pce/cclear.s b/libsrc/pce/cclear.s new file mode 100644 index 000000000..14b9d0e8b --- /dev/null +++ b/libsrc/pce/cclear.s @@ -0,0 +1,25 @@ +; +; Ullrich von Bassewitz, 08.08.1998 +; +; void cclearxy (unsigned char x, unsigned char y, unsigned char length); +; void cclear (unsigned char length); +; + + .export _cclearxy, _cclear + .import gotoxy, cputdirect + .importzp tmp1 + +_cclearxy: + pha ; Save the length + jsr gotoxy ; Call this one, will pop params + pla ; Restore the length and run into _cclear + +_cclear: + cmp #0 ; Is the length zero? + beq L9 ; Jump if done + sta tmp1 +L1: lda #$20 ; Blank - screen code + jsr cputdirect ; Direct output + dec tmp1 + bne L1 +L9: rts diff --git a/libsrc/pce/color.s b/libsrc/pce/color.s index 0ff991a2e..1223d2936 100644 --- a/libsrc/pce/color.s +++ b/libsrc/pce/color.s @@ -5,11 +5,14 @@ ; - .export _textcolor, _bgcolor, _bordercolor + .export _textcolor, _bgcolor, _bordercolor + .import return0 .include "pce.inc" .include "extzp.inc" +_bordercolor = return0 + _textcolor: ldx CHARCOLOR ; get old value sta CHARCOLOR ; set new value @@ -32,11 +35,6 @@ _bgcolor: txa rts -_bordercolor: - lda #0 - tax - rts - .rodata .export colors diff --git a/libsrc/pce/crt0.s b/libsrc/pce/crt0.s index 80b32c089..75ffb7f05 100644 --- a/libsrc/pce/crt0.s +++ b/libsrc/pce/crt0.s @@ -4,33 +4,26 @@ ; by Groepaz/Hitmen <groepaz@gmx.net> ; based on code by Ullrich von Bassewitz <uz@cc65.org> ; -; This must be the *first* file on the linker command line +; 2018-02-11, Greg King ; .export _exit .export __STARTUP__ : absolute = 1 ; Mark as startup .import initlib, donelib - .import push0, _main, zerobss - .import initheap + .import push0, _main .import IRQStub - ; Linker generated - .import __RAM_START__, __RAM_SIZE__ - .import __ROM0_START__, __ROM0_SIZE__ - .import __ROM_START__, __ROM_SIZE__ - .import __STARTUP_LOAD__,__STARTUP_RUN__, __STARTUP_SIZE__ - .import __CODE_LOAD__,__CODE_RUN__, __CODE_SIZE__ - .import __RODATA_LOAD__,__RODATA_RUN__, __RODATA_SIZE__ - .import __DATA_LOAD__,__DATA_RUN__, __DATA_SIZE__ - .import __BSS_SIZE__ + ; Linker-generated + .import __CARTSIZE__ + .import __DATA_LOAD__, __DATA_RUN__, __DATA_SIZE__ + .import __BSS_RUN__, __BSS_SIZE__ + .import __MAIN_START__, __MAIN_SIZE__, __STACKSIZE__ .include "pce.inc" .include "extzp.inc" .importzp sp - .importzp ptr1,ptr2 - .importzp tmp1,tmp2,tmp3 ; ------------------------------------------------------------------------ ; Place the startup code in a special segment. @@ -53,29 +46,27 @@ start: ldx #$FF ; Stack top ($21FF) txs - ; At startup all MPRs are set to 0, so init them - lda #$ff - tam #%00000001 ; 0000-1FFF = Hardware page + ; At power-on, most MPRs have random values; so, initiate them. + lda #$FF + tam #%00000001 ; $0000-$1FFF = Hardware bank lda #$F8 - tam #%00000010 ; 2000-3FFF = Work RAM - - ; FIXME: setup a larger block of memory to use with C-code + tam #%00000010 ; $2000-$3FFF = Work RAM ;lda #$F7 - ;tam #%00000100 ; 4000-5FFF = Save RAM - ;lda #1 - ;tam #%00001000 ; 6000-7FFF Page 2 - ;lda #2 - ;tam #%00010000 ; 8000-9FFF Page 3 - ;lda #3 - ;tam #%00100000 ; A000-BFFF Page 4 + ;tam #%00000100 ; $4000-$47FF = 2K Battery-backed RAM ;lda #4 - ;tam #%01000000 ; C000-DFFF Page 5 - ;lda #0 - ;tam #%10000000 ; e000-fFFF hucard/syscard bank 0 + ;tam #%00001000 ; $6000-$7FFF - ; Clear work RAM (2000-3FFF) - stz <$00 - tii $2000, $2001, $1FFF + lda #$01 + ldx #>$8000 + cpx #>__CARTSIZE__ + bcc @L1 ;(blt) + tam #%00010000 ; $8000-$9FFF = ROM bank 1 (32K block of ROM) + inc a + tam #%00100000 ; $A000-$BFFF = ROM bank 2 + inc a +@L1: tam #%01000000 ; $C000-$DFFF = ROM bank 3 (32K) or 1 (16K) + ;lda #$00 ; (The reset default) + ;tam #%10000000 ; $E000-$FFFF hucard/syscard bank 0 ; Initialize hardware stz TIMER_CTRL ; Timer off @@ -91,15 +82,16 @@ start: lda #$05 sta IRQ_MASK ; IRQ1=on - ; Clear the BSS data - jsr zerobss - ; Copy the .data segment to RAM tii __DATA_LOAD__, __DATA_RUN__, __DATA_SIZE__ + ; Clear the .bss segment + stz __BSS_RUN__ + tii __BSS_RUN__, __BSS_RUN__ + 1, __BSS_SIZE__ - 1 + ; Set up the stack - lda #<(__RAM_START__+__RAM_SIZE__) - ldx #>(__RAM_START__+__RAM_SIZE__) + lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) + ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__) sta sp stx sp + 1 diff --git a/libsrc/pce/joy/pce-stdjoy.s b/libsrc/pce/joy/pce-stdjoy.s index ab25134dd..c0f338f90 100644 --- a/libsrc/pce/joy/pce-stdjoy.s +++ b/libsrc/pce/joy/pce-stdjoy.s @@ -30,7 +30,6 @@ .addr UNINSTALL .addr COUNT .addr READJOY - .addr 0 ; IRQ entry unused ; ------------------------------------------------------------------------ ; Constants diff --git a/libsrc/pce/wherex.s b/libsrc/pce/wherex.s new file mode 100644 index 000000000..3abe49cb6 --- /dev/null +++ b/libsrc/pce/wherex.s @@ -0,0 +1,24 @@ +; +; Ullrich von Bassewitz, 2003-05-02 +; +; unsigned char wherex (void); +; + + .export _wherex + + .include "pce.inc" + .include "extzp.inc" + +.proc _wherex + + lda CURS_X + ldx #$00 + rts + +.endproc + +;------------------------------------------------------------------------------- +; force the init constructor to be imported + + .import initconio +conio_init = initconio diff --git a/libsrc/pce/wherey.s b/libsrc/pce/wherey.s new file mode 100644 index 000000000..7061790ab --- /dev/null +++ b/libsrc/pce/wherey.s @@ -0,0 +1,24 @@ +; +; Ullrich von Bassewitz, 2003-05-02 +; +; unsigned char wherey (void); +; + + .export _wherey + + .include "pce.inc" + .include "extzp.inc" + +.proc _wherey + + lda CURS_Y + ldx #$00 + rts + +.endproc + +;------------------------------------------------------------------------------- +; force the init constructor to be imported + + .import initconio +conio_init = initconio diff --git a/libsrc/pet/cpeekcolor.s b/libsrc/pet/cpeekcolor.s new file mode 100644 index 000000000..ed275ec95 --- /dev/null +++ b/libsrc/pet/cpeekcolor.s @@ -0,0 +1,8 @@ +; +; 2017-06-03, Greg King +; +; unsigned char cpeekcolor (void); +; + + .import return1 + .export _cpeekcolor := return1 ; always COLOR_WHITE diff --git a/libsrc/pet/joy/pet-ptvjoy.s b/libsrc/pet/joy/pet-ptvjoy.s index 3bb368355..c098072fb 100644 --- a/libsrc/pet/joy/pet-ptvjoy.s +++ b/libsrc/pet/joy/pet-ptvjoy.s @@ -10,6 +10,7 @@ .include "joy-kernel.inc" .include "joy-error.inc" + .include "pet.inc" .macpack module @@ -34,17 +35,12 @@ .addr UNINSTALL .addr COUNT .addr READ - .addr 0 ; IRQ entry unused ; ------------------------------------------------------------------------ ; Constants JOY_COUNT = 2 ; Number of joysticks we support -VIA_PRA := $E841 ; Port register A -VIA_DDRA := $E843 ; Data direction register A - - .code ; ------------------------------------------------------------------------ @@ -90,9 +86,9 @@ READ: lda #%10000000 ; via port A Data-Direction ; Read joystick 1 joy1: lda #$80 ; via port A read/write - sta VIA_PRA ; (output one at PA7) + sta VIA_PA1 ; (output one at PA7) - lda VIA_PRA ; via port A read/write + lda VIA_PA1 ; via port A read/write and #$1f ; get bit 4-0 (PA4-PA0) eor #$1f rts @@ -100,13 +96,13 @@ joy1: lda #$80 ; via port A read/write ; Read joystick 2 joy2: lda #$00 ; via port A read/write - sta VIA_PRA ; (output zero at PA7) + sta VIA_PA1 ; (output zero at PA7) - lda VIA_PRA ; via port A read/write + lda VIA_PA1 ; via port A read/write and #$0f ; get bit 3-0 (PA3-PA0) sta tmp1 ; joy 4 directions - lda VIA_PRA ; via port A read/write + lda VIA_PA1 ; via port A read/write and #%00100000 ; get bit 5 (PA5) lsr ora tmp1 diff --git a/libsrc/pet/joy/pet-stdjoy.s b/libsrc/pet/joy/pet-stdjoy.s index 29c6de627..75b9f7465 100644 --- a/libsrc/pet/joy/pet-stdjoy.s +++ b/libsrc/pet/joy/pet-stdjoy.s @@ -33,7 +33,6 @@ .addr UNINSTALL .addr COUNT .addr READ - .addr 0 ; IRQ entry unused ; ------------------------------------------------------------------------ ; Constants @@ -86,7 +85,7 @@ READ: joy1: lda #0 sta VIA_DDRA - lda VIA_PRA + lda VIA_PA1 and #$0f cmp #$0c bne @notc1 @@ -103,7 +102,7 @@ joy1: joy2: lda #0 sta VIA_DDRA - lda VIA_PRA + lda VIA_PA1 lsr lsr lsr diff --git a/libsrc/plus4/fast.s b/libsrc/plus4/fast.s new file mode 100644 index 000000000..e48813969 --- /dev/null +++ b/libsrc/plus4/fast.s @@ -0,0 +1,22 @@ +; +; Marco van den Heuvel, 2018-03-20 +; +; void fast (void); +; /* Switch the CPU into double clock mode. */ +; + + .export _fast + + .include "plus4.inc" + + +.proc _fast + + lda TED_CLK + and #%11111101 + sta TED_CLK + rts + +.endproc + + diff --git a/libsrc/plus4/isfast.s b/libsrc/plus4/isfast.s new file mode 100644 index 000000000..ff104d97f --- /dev/null +++ b/libsrc/plus4/isfast.s @@ -0,0 +1,22 @@ +; +; Marco van den Heuvel, 2018-03-20 +; +; unsigned char isfast (void); +; /* Returns 1 if the CPU is in double clock mode. */ +; + + .export _isfast + + .include "plus4.inc" + + +.proc _isfast + + lda TED_CLK + lsr + and #$01 + ldx #$00 + rts + +.endproc + diff --git a/libsrc/plus4/joy/plus4-stdjoy.s b/libsrc/plus4/joy/plus4-stdjoy.s index d998b2699..e8e85fedc 100644 --- a/libsrc/plus4/joy/plus4-stdjoy.s +++ b/libsrc/plus4/joy/plus4-stdjoy.s @@ -37,7 +37,6 @@ .addr UNINSTALL .addr COUNT .addr READ - .addr 0 ; IRQ entry unused ; ------------------------------------------------------------------------ ; Constants diff --git a/libsrc/plus4/slow.s b/libsrc/plus4/slow.s new file mode 100644 index 000000000..18b8c231c --- /dev/null +++ b/libsrc/plus4/slow.s @@ -0,0 +1,22 @@ +; +; Marco van den Heuvel, 2018-03-28 +; +; void slow (void); +; /* Switch the CPU into single clock mode. */ +; + + .export _slow + + .include "plus4.inc" + + +.proc _slow + + lda TED_CLK + ora #%00000010 + sta TED_CLK + rts + +.endproc + + diff --git a/libsrc/runtime/incaxy.s b/libsrc/runtime/incaxy.s index 0ee7d879f..faeacf709 100644 --- a/libsrc/runtime/incaxy.s +++ b/libsrc/runtime/incaxy.s @@ -1,7 +1,7 @@ ; ; Ullrich von Bassewitz, 05.08.1998 ; -; CC65 runtime: Increment ax by valie in y +; CC65 runtime: Increment ax by value in y ; .export incaxy, incax4 diff --git a/libsrc/runtime/incsp2.s b/libsrc/runtime/incsp2.s index 067154b86..0ed0ffcdf 100644 --- a/libsrc/runtime/incsp2.s +++ b/libsrc/runtime/incsp2.s @@ -2,7 +2,7 @@ ; Ullrich von Bassewitz, 25.10.2000 ; ; CC65 runtime: Increment the stackpointer by 2. For performance reasons, -; this modules does also contain the popax function. +; this module also contains the popax function. .export popax, incsp2 .importzp sp diff --git a/libsrc/runtime/jmpvec.s b/libsrc/runtime/jmpvec.s index ed77a0789..29a18b1db 100644 --- a/libsrc/runtime/jmpvec.s +++ b/libsrc/runtime/jmpvec.s @@ -1,7 +1,7 @@ ; ; Ullrich von Bassewitz, 2002-12-26 ; -; CC65 runtime: Jump vector that resides in the data segment so it's address +; CC65 runtime: Jump vector that resides in the data segment so its address ; may be patched at runtime. ; diff --git a/libsrc/runtime/ldec.s b/libsrc/runtime/ldec.s index 53b60095d..f8e59d5c0 100644 --- a/libsrc/runtime/ldec.s +++ b/libsrc/runtime/ldec.s @@ -1,5 +1,6 @@ ; -; Ullrich von Bassewitz, 29.12.1999 +; Piotr Fusik, 09.03.2018 +; originally by Ullrich von Bassewitz ; ; CC65 runtime: Decrement eax by value in Y ; @@ -11,16 +12,25 @@ deceaxy: sty tmp1 sec sbc tmp1 - sta tmp1 - txa - sbc #0 - tax - lda sreg - sbc #0 - sta sreg - lda sreg+1 - sbc #0 - sta sreg+1 - lda tmp1 - rts + bcs @L9 + +; Borrow from X. + + dex + cpx #$FF + bne @L9 + +; X wrapped from zero to $FF, borrow from sreg. + + dec sreg + cpx sreg + bne @L9 + +; sreg wrapped from zero to $FF, borrow from sreg+1. + + dec sreg+1 + +; Done. + +@L9: rts diff --git a/libsrc/runtime/mulax3.s b/libsrc/runtime/mulax3.s index c35b05dcc..472bc60ec 100644 --- a/libsrc/runtime/mulax3.s +++ b/libsrc/runtime/mulax3.s @@ -1,7 +1,7 @@ ; ; Ullrich von Bassewitz, 04.10.2001 ; -; CC65 runtime: Multiply the primary register +; CC65 runtime: Multiply the primary register by 3 ; .export mulax3 diff --git a/libsrc/runtime/mulax5.s b/libsrc/runtime/mulax5.s index 9af599806..7e5ed11d9 100644 --- a/libsrc/runtime/mulax5.s +++ b/libsrc/runtime/mulax5.s @@ -1,7 +1,7 @@ ; ; Ullrich von Bassewitz, 04.10.2001 ; -; CC65 runtime: Multiply the primary register +; CC65 runtime: Multiply the primary register by 5 ; .export mulax5 diff --git a/libsrc/supervision/joy/supervision-stdjoy.s b/libsrc/supervision/joy/supervision-stdjoy.s new file mode 100644 index 000000000..d233a8600 --- /dev/null +++ b/libsrc/supervision/joy/supervision-stdjoy.s @@ -0,0 +1,81 @@ +; +; Standard joystick driver for the Supervision +; + + .include "joy-kernel.inc" + .include "joy-error.inc" + .include "supervision.inc" + + .macpack module + + +; ------------------------------------------------------------------------ +; Header. Includes jump table + + module_header _supervision_stdjoy_joy + +; Driver signature + + .byte $6A, $6F, $79 ; "joy" + .byte JOY_API_VERSION ; Driver API version number + +; Library reference + + .addr $0000 + +; Jump table. + + .addr INSTALL + .addr UNINSTALL + .addr COUNT + .addr READJOY + +; ------------------------------------------------------------------------ +; Constants + +JOY_COUNT = 1 ; Number of joysticks we support + + +.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 JOY_ERR_xx code in a/x. +; + +INSTALL: + lda #<JOY_ERR_OK + ldx #>JOY_ERR_OK + +; rts ; Run into UNINSTALL instead + +; ------------------------------------------------------------------------ +; DEINSTALL routine. Is called before the driver is removed from memory. +; Can do cleanup or whatever. Must not return anything. +; + +UNINSTALL: + rts + + +; ------------------------------------------------------------------------ +; COUNT: Return the total number of available joysticks in a/x. +; +;unsigned char __fastcall__ joy_count (void); + +COUNT: + lda #<JOY_COUNT + ldx #>JOY_COUNT + rts + +; ------------------------------------------------------------------------ +; READ: Read a particular joystick passed in A. +; +;unsigned char __fastcall__ joy_read (unsigned char joystick); + +READJOY: + lda sv_control + ldx #0 + rts diff --git a/libsrc/supervision/joy_stat_stddrv.s b/libsrc/supervision/joy_stat_stddrv.s new file mode 100644 index 000000000..4daa13e34 --- /dev/null +++ b/libsrc/supervision/joy_stat_stddrv.s @@ -0,0 +1,12 @@ +; +; Address of the static standard joystick driver +; +; Oliver Schmidt, 2012-11-01 +; +; const void joy_static_stddrv[]; +; + + .export _joy_static_stddrv + .import _supervision_stdjoy_joy + +_joy_static_stddrv := _supervision_stdjoy_joy diff --git a/libsrc/supervision/libref.s b/libsrc/supervision/libref.s new file mode 100644 index 000000000..e4afa7eb1 --- /dev/null +++ b/libsrc/supervision/libref.s @@ -0,0 +1,8 @@ +; +; Oliver Schmidt, 2013-05-31 +; + + .export joy_libref + .import _exit + +joy_libref := _exit diff --git a/libsrc/telestrat/cgetc.s b/libsrc/telestrat/cgetc.s new file mode 100644 index 000000000..6a6b23318 --- /dev/null +++ b/libsrc/telestrat/cgetc.s @@ -0,0 +1,28 @@ +; +; jede jede@oric.org 2017-10-01 +; + .export _cgetc + + .import cursor + + .include "telestrat.inc" + +.proc _cgetc + ; this routine could be quicker if we wrote in page 2 variables, + ; but it's better to use telemon routine in that case, because telemon can manage 4 I/O + ldx cursor ; if cursor equal to 0, then switch off cursor + beq switchoff_cursor + + ldx #$00 ; x is the first screen + BRK_TELEMON(XCSSCR) ; display cursor + jmp loop ; could be replaced by a bne/beq but 'jmp' is cleaner than a bne/beq which could expect some matters + +switchoff_cursor: + ; at this step X is equal to $00, X must be set, because it's the id of the screen (telestrat can handle 4 virtuals screen) + BRK_TELEMON(XCOSCR) ; switch off cursor + +loop: + BRK_TELEMON XRD0 ; waits until key is pressed + bcs loop + rts +.endproc diff --git a/libsrc/telestrat/chline.s b/libsrc/telestrat/chline.s new file mode 100644 index 000000000..6ead10eee --- /dev/null +++ b/libsrc/telestrat/chline.s @@ -0,0 +1,22 @@ +; +; jede jede@oric.org 2018-04-17 +; + +; void chline (unsigned char length); +; + + .export _chline + .include "telestrat.inc" + .include "zeropage.inc" + + +.proc _chline + sta tmp1 +@loop: + lda #'-' ; horizontal line screen code + BRK_TELEMON XWR0 ; macro send char to screen (channel 0 in telemon terms) + dec tmp1 + bne @loop + rts +.endproc + diff --git a/libsrc/telestrat/clrscr.s b/libsrc/telestrat/clrscr.s index f2b8fafc1..31c8ee205 100644 --- a/libsrc/telestrat/clrscr.s +++ b/libsrc/telestrat/clrscr.s @@ -9,6 +9,9 @@ .include "telestrat.inc" .proc _clrscr + ; Switch to text mode + BRK_TELEMON(XTEXT) + lda #<SCREEN ldy #>SCREEN sta RES diff --git a/libsrc/telestrat/cputc.s b/libsrc/telestrat/cputc.s new file mode 100644 index 000000000..b4f2966a4 --- /dev/null +++ b/libsrc/telestrat/cputc.s @@ -0,0 +1,15 @@ +; 2018-04-13, Jede (jede@oric.org) +; + +; void cputc (char c); +; + + .export _cputc + + .include "telestrat.inc" + +.proc _cputc + BRK_TELEMON XWR0 ; macro send char to screen (channel 0 in telemon terms) + rts +.endproc + diff --git a/libsrc/telestrat/initcwd.s b/libsrc/telestrat/initcwd.s index f359ebeb4..dc3c53257 100644 --- a/libsrc/telestrat/initcwd.s +++ b/libsrc/telestrat/initcwd.s @@ -10,22 +10,19 @@ initcwd: - ldx #PWD_PTR BRK_TELEMON XVARS - + sta ptr1 sty ptr1+1 - + ldy #$00 - -loop: +loop: lda (ptr1),y - beq done sta __cwd,y + beq done iny bne loop - -done: - sta __cwd,y + +done: rts diff --git a/libsrc/telestrat/irq.s b/libsrc/telestrat/irq.s new file mode 100644 index 000000000..9027f263e --- /dev/null +++ b/libsrc/telestrat/irq.s @@ -0,0 +1,59 @@ +; +; IRQ handling (Oric version) +; + + .export initirq, doneirq + .import callirq + + .include "telestrat.inc" + +; ------------------------------------------------------------------------ + +.segment "ONCE" + +initirq: + lda IRQVec + ldx IRQVec+1 + sta IRQInd+1 + stx IRQInd+2 + lda #<IRQStub + ldx #>IRQStub + jmp setvec + +; ------------------------------------------------------------------------ + +.code + +doneirq: + lda IRQInd+1 + ldx IRQInd+2 +setvec: sei + sta IRQVec + stx IRQVec+1 + cli + rts + +; ------------------------------------------------------------------------ + +.segment "LOWCODE" + +IRQStub: + cld ; Just to be sure + pha + txa + pha + tya + pha + jsr callirq ; Call the functions + pla + tay + pla + tax + pla + jmp IRQInd ; Jump to the saved IRQ vector + +; ------------------------------------------------------------------------ + +.data + +IRQInd: jmp $0000 diff --git a/libsrc/telestrat/libref.s b/libsrc/telestrat/libref.s new file mode 100644 index 000000000..bdd0a671a --- /dev/null +++ b/libsrc/telestrat/libref.s @@ -0,0 +1,8 @@ +; +; Jede (jede@oric.org), 2017-10-16 +; + + .export tgi_libref + .import _exit + +tgi_libref := _exit diff --git a/libsrc/telestrat/oserror.s b/libsrc/telestrat/oserror.s new file mode 100644 index 000000000..e3b9e619a --- /dev/null +++ b/libsrc/telestrat/oserror.s @@ -0,0 +1,17 @@ +; +; Jede, 2017-10-27 +; +; int __fastcall__ _osmaperrno (unsigned char oserror); +; /* Map a system specific error into a system independent code */ +; + + .include "errno.inc" + .export __osmaperrno + +.proc __osmaperrno + + lda #<EUNKNOWN + ldx #>EUNKNOWN + rts + +.endproc diff --git a/libsrc/telestrat/sysmkdir.s b/libsrc/telestrat/sysmkdir.s new file mode 100644 index 000000000..26d97c4b0 --- /dev/null +++ b/libsrc/telestrat/sysmkdir.s @@ -0,0 +1,30 @@ +; +; Jede (jede@oric.org), 2017-10-27 +; +; unsigned char _sysmkdir (const char* name, ...); +; + + .export __sysmkdir + .import addysp, popax + + .include "telestrat.inc" + .include "zeropage.inc" + + +__sysmkdir: + ; Throw away all parameters except the name + dey + dey + jsr addysp + + ; Get name + jsr popax + + ; Call telemon primitive + + BRK_TELEMON(XMKDIR) + + rts + + + diff --git a/libsrc/telestrat/sysremove.s b/libsrc/telestrat/sysremove.s new file mode 100644 index 000000000..565dfc111 --- /dev/null +++ b/libsrc/telestrat/sysremove.s @@ -0,0 +1,16 @@ +; +; Jede, 10.11.2017 +; +; unsigned char __fastcall__ _sysremove (const char* name); +; + + .export __sysremove + + + .include "zeropage.inc" + .include "telestrat.inc" + +__sysremove: + ; Push name + BRK_TELEMON(XRM) + rts diff --git a/libsrc/telestrat/tgi/telestrat-228-200-3.s b/libsrc/telestrat/tgi/telestrat-228-200-3.s new file mode 100644 index 000000000..ce501f0bf --- /dev/null +++ b/libsrc/telestrat/tgi/telestrat-228-200-3.s @@ -0,0 +1,373 @@ +; +; Graphics driver for the 228x200x3 palette mode on the Telestrat +; +; Jede (jede@oric.org), 2017-10-15 + + .include "zeropage.inc" + + .include "tgi-kernel.inc" + .include "tgi-error.inc" + .include "telestrat.inc" + + .macpack generic + .macpack module + +XSIZE = 6 ; System font width +YSIZE = 8 ; System font height + +; ------------------------------------------------------------------------ +; Header. Includes jump table and constants. + + module_header _telestrat_228_200_3_tgi + +; The first part of the header is a structure that has a signature, +; and defines the capabilities of the driver. + + .byte "tgi" + .byte TGI_API_VERSION ; TGI API version number + .addr $0000 ; Library reference + .word 228 ; x resolution + .word 200 ; y resolution + .byte 3 ; Number of drawing colors + .byte 1 ; Number of screens available + .byte XSIZE ; System font x size + .byte YSIZE ; System font y size + .word $011C ; Aspect ratio (based on 4/3 display) + .byte 0 ; TGI driver flags + +; Next comes the jump table. Currently, all entries must be valid; +; and, may point to an RTS, for test versions (function not implemented). + + .addr INSTALL + .addr UNINSTALL + .addr INIT + .addr DONE + .addr GETERROR + .addr CONTROL + .addr CLEAR + .addr SETVIEWPAGE + .addr SETDRAWPAGE + .addr SETCOLOR + .addr SETPALETTE + .addr GETPALETTE + .addr GETDEFPALETTE + .addr SETPIXEL + .addr GETPIXEL + .addr LINE + .addr BAR + .addr CIRCLE + .addr TEXTSTYLE + .addr OUTTEXT + +; ------------------------------------------------------------------------ +; Data. + +; Variables mapped to the zero-page segment variables. These are +; used for passing parameters to the driver. + +X1 := ptr1 +Y1 := ptr2 +X2 := ptr3 +Y2 := ptr4 + +; Absolute variables used in the code + +.bss + +ERROR: .res 1 ; Error code +MODE: .res 1 ; Graphics mode +PALETTE: .res 2 + +; Constant table + +.rodata + +; Default colors: black background, white foreground +; (The third "color" actually flips a pixel +; between the foreground and background colors.) +; +DEFPALETTE: .byte 0, 1 + +.code + +; ------------------------------------------------------------------------ +; INIT: Changes an already installed device from text mode to graphics mode. +; Note that INIT/DONE may be called multiple times while the driver +; is loaded, while INSTALL is called only once. So, any code that is needed +; to initialize variables and so on must go here. Setting palette and +; clearing the screen are not needed because they are called by the graphics +; kernel later. +; The graphics kernel never will call INIT when a graphics mode is already +; active, so there is no need to protect against that. +; +; Must set an error code: YES +; + +INIT: + +; Switch into graphics mode. + BRK_TELEMON(XHIRES) + +; Done, reset the error code. + + lda #TGI_ERR_OK + sta ERROR + rts + +; ------------------------------------------------------------------------ +; GETERROR: Return the error code in A, and clear it. + +GETERROR: + ldx #TGI_ERR_OK + lda ERROR + stx ERROR + rts +; ------------------------------------------------------------------------ +; INSTALL routine. Is called after the driver is loaded into memory. May +; initialize anything that has to be done just once. Is probably empty +; most of the time. +; +; Must set an error code: NO +; + +INSTALL: + +; ------------------------------------------------------------------------ +; UNINSTALL routine. Is called before the driver is removed from memory. May +; clean up anything done by INSTALL, but probably is empty most of the time. +; +; Must set an error code: NO +; + +UNINSTALL: + rts + +; ------------------------------------------------------------------------ +; DONE: Will be called to switch the graphics device back into text mode. +; The graphics kernel never will call DONE when no graphics mode is active, +; so there is no need to protect against that. +; +; Must set an error code: NO +; + +DONE: + BRK_TELEMON(XTEXT) + rts +; ------------------------------------------------------------------------ +; CONTROL: Platform-/driver-specific entry point. +; +; Must set an error code: YES +; + +CONTROL: + ; not done yet + rts + +; ------------------------------------------------------------------------ +; CLEAR: Clears the screen. +; +; Must set an error code: NO +; + +CLEAR: + ; not done yet + rts + +; ------------------------------------------------------------------------ +; SETVIEWPAGE: Set the visible page. Called with the new page in A (0..n). +; The page number already is checked to be valid, by the graphics kernel. +; +; Must set an error code: NO (will be called only if page OK) +; + +SETVIEWPAGE: + +; ------------------------------------------------------------------------ +; SETDRAWPAGE: Set the drawable page. Called with the new page in A (0..n). +; The page number already is checked to be valid, by the graphics kernel. +; +; Must set an error code: NO (will be called only if page OK) +; + +SETDRAWPAGE: + rts + +; ------------------------------------------------------------------------ +; SETCOLOR: Set the drawing color (in A). The new color already is checked +; to be in a valid range (0..maxcolor-1). +; +; Must set an error code: NO (will be called only if color OK) +; + +SETCOLOR: + ; not done yet + rts + +; ------------------------------------------------------------------------ +; SETPALETTE: Set the palette (not available with all drivers/hardware). +; A pointer to the palette is passed in ptr1. Must set an error if palettes +; are not supported. +; +; Must set an error code: YES +; + +SETPALETTE: + ; not done yet + rts + +flipcolor: + ; not done yet + rts + +; ------------------------------------------------------------------------ +; GETPALETTE: Return the current palette in A/X. Even drivers that cannot +; set the palette should return the default palette here, so there's no +; way for this function to fail. +; +; Must set an error code: NO +; + +GETPALETTE: + ; not done yet + rts + +; ------------------------------------------------------------------------ +; GETDEFPALETTE: Return the default palette for the driver in A/X. All +; drivers should return something reasonable here, even drivers that don't +; support palettes; otherwise, the caller has no way to determine the colors +; of the (not changeable) palette. +; +; Must set an error code: NO (all drivers must have a default palette) +; + +GETDEFPALETTE: + lda #<DEFPALETTE + ldx #>DEFPALETTE + rts + +; ------------------------------------------------------------------------ +; SETPIXEL: Draw one pixel at X1/Y1 = ptr1/ptr2 with the current drawing +; color. The co-ordinates passed to this function are never outside the +; visible screen area, so there is no need for clipping inside this function. +; +; Must set an error code: NO +; + +SETPIXEL: + lda #$80 + +SETPIXELSETMODE: + sta HRSFB + lda X1 + sta HRS1 + lda Y1 + sta HRS2 + + + + BRK_TELEMON(XCURSE) + + rts + +; ------------------------------------------------------------------------ +; GETPIXEL: Read the color value of a pixel, and return it in A/X. The +; co-ordinates passed to this function are never outside the visible screen +; area, so there is no need for clipping inside this function. + +GETPIXEL: + ; not done yet + rts + +; ------------------------------------------------------------------------ +; LINE: Draw a line from X1/Y1 to X2/Y2, where X1/Y1 = ptr1/ptr2 and +; X2/Y2 = ptr3/ptr4, using the current drawing color. +; +; Must set an error code: NO +; + +LINE: + ; not done yet + lda X1 + sta HRS1 + lda Y1 + sta HRS2 + + lda X2 + sta HRS3 + lda Y2 + sta HRS4 + + lda #$ff + sta HRSPAT + + BRK_TELEMON(XDRAWA) + rts + + + +CIRCLE: + ; not done yet + rts + +; ------------------------------------------------------------------------ +; BAR: Draw a filled rectangle with the corners X1/Y1, X2/Y2, where +; X1/Y1 = ptr1/ptr2 and X2/Y2 = ptr3/ptr4, using the current drawing color. +; Contrary to most other functions, the graphics kernel will sort and clip +; the co-ordinates before calling the driver; so, on entry, the following +; conditions are valid: +; X1 <= X2 +; Y1 <= Y2 +; (X1 >= 0) && (X1 < XRES) +; (X2 >= 0) && (X2 < XRES) +; (Y1 >= 0) && (Y1 < YRES) +; (Y2 >= 0) && (Y2 < YRES) +; +; Must set an error code: NO +; + +BAR: + ; not done yet + rts + +; ------------------------------------------------------------------------ +; TEXTSTYLE: Set the style used when calling OUTTEXT. Text scaling in the x +; and y directions is passed in X/Y, the text direction is passed in A. +; +; Must set an error code: NO +; + +TEXTSTYLE: + rts + + +; ------------------------------------------------------------------------ +; OUTTEXT: Output text at x/y = ptr1/ptr2, using the current color and the +; current text style. The text to output is given as a zero-terminated +; string with its address in ptr3. +; +; Must set an error code: NO +; + +OUTTEXT: + ; put hires cursor in X & Y + lda #$00 + jsr SETPIXELSETMODE + + + ; count the length of the string + ldy #$00 +loop: + lda (ptr3),y + beq out + iny + bne loop +out: + ; XSCHAR routine from telemon needs to have the length of the string in X register + ; copy Y register to X register. It could be optimized in 65C02 with TYX + tya + tax + + lda ptr3 ; XSCHAR needs in A and Y the adress of the string + ldy ptr3+1 + BRK_TELEMON(XSCHAR) + rts diff --git a/libsrc/telestrat/tgi/telestrat-240-200-2.s b/libsrc/telestrat/tgi/telestrat-240-200-2.s new file mode 100644 index 000000000..3ee918c4f --- /dev/null +++ b/libsrc/telestrat/tgi/telestrat-240-200-2.s @@ -0,0 +1,365 @@ +; +; Graphics driver for the 240x200x2 monochrome mode on the Atmos +; +; Jede (jede@oric.org), 2017-10-15 + + + .include "zeropage.inc" + + .include "tgi-kernel.inc" + .include "tgi-error.inc" + .include "telestrat.inc" + + .macpack generic + .macpack module + +XSIZE = 6 ; System font width +YSIZE = 8 ; System font height + +; ------------------------------------------------------------------------ +; Header. Includes jump table and constants. + + module_header _telestrat_240_200_2_tgi + +; First part of the header is a structure that has a magic and defines the +; capabilities of the driver + + .byte $74, $67, $69 ; "tgi" + .byte TGI_API_VERSION ; TGI API version number + .addr $0000 ; Library reference + .word 240 ; X resolution + .word 200 ; Y resolution + .byte 2 ; Number of drawing colors + .byte 1 ; Number of screens available + .byte XSIZE ; System font X size + .byte YSIZE ; System font Y size + .word $011C ; Aspect ratio (based on 4/3 display) + .byte 0 ; TGI driver flags + +; Next comes the jump table. Currently all entries must be valid and may point +; to an RTS for test versions (function not implemented). + + .addr INSTALL + .addr UNINSTALL + .addr INIT + .addr DONE + .addr GETERROR + .addr CONTROL + .addr CLEAR + .addr SETVIEWPAGE + .addr SETDRAWPAGE + .addr SETCOLOR + .addr SETPALETTE + .addr GETPALETTE + .addr GETDEFPALETTE + .addr SETPIXEL + .addr GETPIXEL + .addr LINE + .addr BAR + .addr TEXTSTYLE + .addr OUTTEXT + +; ------------------------------------------------------------------------ +; Data. + +; Variables mapped to the zero page segment variables. Some of these are +; used for passing parameters to the driver. + +X1 := ptr1 +Y1 := ptr2 +X2 := ptr3 +Y2 := ptr4 + +; Absolute variables used in the code + +.bss + +ERROR: .res 1 ; Error code +MODE: .res 1 ; Graphics mode + +; Constant table + +.rodata + +DEFPALETTE: .byte 0, 1 + +.code + +; ------------------------------------------------------------------------ +; INSTALL routine. Is called after the driver is loaded into memory. May +; initialize anything that has to be done just once. Is probably empty +; most of the time. +; +; Must set an error code: NO +; + +INSTALL: + +; ------------------------------------------------------------------------ +; UNINSTALL routine. Is called before the driver is removed from memory. May +; clean up anything done by INSTALL but is probably empty most of the time. +; +; Must set an error code: NO +; + +UNINSTALL: + rts + +; ------------------------------------------------------------------------ +; INIT: Changes an already installed device from text mode to graphics +; mode. +; Note that INIT/DONE may be called multiple times while the driver +; is loaded, while INSTALL is only called once, so any code that is needed +; to initializes variables and so on must go here. Setting palette and +; clearing the screen is not needed because this is called by the graphics +; kernel later. +; The graphics kernel will never call INIT when a graphics mode is already +; active, so there is no need to protect against that. +; +; Must set an error code: YES +; + +INIT: + +; Switch into graphics mode + + BRK_TELEMON(XHIRES) + +; Done, reset the error code + + lda #TGI_ERR_OK + sta ERROR + rts + +; ------------------------------------------------------------------------ +; DONE: Will be called to switch the graphics device back into text mode. +; The graphics kernel will never call DONE when no graphics mode is active, +; so there is no need to protect against that. +; +; Must set an error code: NO +; + +DONE: + BRK_TELEMON(XTEXT) + rts + +; ------------------------------------------------------------------------ +; GETERROR: Return the error code in A and clear it. + +GETERROR: + ldx #TGI_ERR_OK + lda ERROR + stx ERROR + rts + +; ------------------------------------------------------------------------ +; CONTROL: Platform/driver specific entry point. +; +; Must set an error code: YES +; + +CONTROL: + ; not done yet + rts + +; ------------------------------------------------------------------------ +; CLEAR: Clears the screen. +; +; Must set an error code: NO +; + +CLEAR: + ; not done yet + rts + +; ------------------------------------------------------------------------ +; SETVIEWPAGE: Set the visible page. Called with the new page in A (0..n). +; The page number is already checked to be valid by the graphics kernel. +; +; Must set an error code: NO (will only be called if page ok) +; + +SETVIEWPAGE: + +; ------------------------------------------------------------------------ +; SETDRAWPAGE: Set the drawable page. Called with the new page in A (0..n). +; The page number is already checked to be valid by the graphics kernel. +; +; Must set an error code: NO (will only be called if page ok) +; + +SETDRAWPAGE: + rts + +; ------------------------------------------------------------------------ +; SETCOLOR: Set the drawing color (in A). The new color is already checked +; to be in a valid range (0..maxcolor-1). +; +; Must set an error code: NO (will only be called if color ok) +; + +SETCOLOR: + ;not done yet + rts + +; ------------------------------------------------------------------------ +; SETPALETTE: Set the palette (not available with all drivers/hardware). +; A pointer to the palette is passed in ptr1. Must set an error if palettes +; are not supported +; +; Must set an error code: YES +; + +SETPALETTE: + lda #TGI_ERR_INV_FUNC ; This resolution has no palette + sta ERROR + rts + +; ------------------------------------------------------------------------ +; GETPALETTE: Return the current palette in A/X. Even drivers that cannot +; set the palette should return the default palette here, so there's no +; way for this function to fail. +; +; Must set an error code: NO +; + +GETPALETTE: + +; ------------------------------------------------------------------------ +; GETDEFPALETTE: Return the default palette for the driver in A/X. All +; drivers should return something reasonable here, even drivers that don't +; support palettes, otherwise the caller has no way to determine the colors +; of the (not changeable) palette. +; +; Must set an error code: NO (all drivers must have a default palette) +; + +GETDEFPALETTE: + ; not done yet + rts + +; ------------------------------------------------------------------------ +; SETPIXEL: Draw one pixel at X1/Y1 = ptr1/ptr2 with the current drawing +; color. The coordinates passed to this function are never outside the +; visible screen area, so there is no need for clipping inside this function. +; +; Must set an error code: NO +; + +SETPIXEL: + lda #$80 ; curset on +SETPIXELSETMODE: + sta HRSFB + + lda X1 + sta HRS1 + lda Y1 + sta HRS2 + + + + BRK_TELEMON(XCURSE) + + rts + +; ------------------------------------------------------------------------ +; GETPIXEL: Read the color value of a pixel and return it in A/X. The +; coordinates passed to this function are never outside the visible screen +; area, so there is no need for clipping inside this function. + +GETPIXEL: + ; not done yet + rts + +; ------------------------------------------------------------------------ +; LINE: Draw a line from X1/Y1 to X2/Y2, where X1/Y1 = ptr1/ptr2 and +; X2/Y2 = ptr3/ptr4 using the current drawing color. +; +; Must set an error code: NO +; + +LINE: + + lda X1 + sta HRS1 + lda Y1 + sta HRS2 + + lda X2 + sta HRS3 + lda Y2 + sta HRS4 + + lda #$ff + sta HRSPAT + + BRK_TELEMON(XDRAWA) + + rts + +CIRCLE: + ; not done yet + rts + +; ------------------------------------------------------------------------ +; BAR: Draw a filled rectangle with the corners X1/Y1, X2/Y2, where +; X1/Y1 = ptr1/ptr2 and X2/Y2 = ptr3/ptr4 using the current drawing color. +; Contrary to most other functions, the graphics kernel will sort and clip +; the coordinates before calling the driver, so on entry the following +; conditions are valid: +; X1 <= X2 +; Y1 <= Y2 +; (X1 >= 0) && (X1 < XRES) +; (X2 >= 0) && (X2 < XRES) +; (Y1 >= 0) && (Y1 < YRES) +; (Y2 >= 0) && (Y2 < YRES) +; +; Must set an error code: NO +; + +BAR: + ; not done yet + rts + +; ------------------------------------------------------------------------ +; TEXTSTYLE: Set the style used when calling OUTTEXT. Text scaling in X and Y +; direction is passend in X/Y, the text direction is passed in A. +; +; Must set an error code: NO +; + +TEXTSTYLE: + rts + + +; ------------------------------------------------------------------------ +; OUTTEXT: Output text at X/Y = ptr1/ptr2 using the current color and the +; current text style. The text to output is given as a zero terminated +; string with address in ptr3. +; +; Must set an error code: NO +; + +OUTTEXT: + ; put hires cursor in X & Y + lda #$00 + jsr SETPIXELSETMODE + + + ; count the length of the string + ldy #$00 +loop: + lda (ptr3),y + beq out + iny + bne loop +out: + ; XSCHAR routine from telemon needs to have the length of the string in X register + ; copy Y register to X register. It could be optimized in 65C02 with TYX + tya + tax + + lda ptr3 ; XSCHAR needs in A and Y the adress of the string + ldy ptr3+1 + BRK_TELEMON(XSCHAR) + rts diff --git a/libsrc/telestrat/tgi_stat_stddrv.s b/libsrc/telestrat/tgi_stat_stddrv.s new file mode 100644 index 000000000..2b0d96761 --- /dev/null +++ b/libsrc/telestrat/tgi_stat_stddrv.s @@ -0,0 +1,14 @@ +; +; Address of the static standard tgi driver +; +; Jede (jede@oric.org), 2017-10-15 +; +; const void tgi_static_stddrv[]; +; + + .export _tgi_static_stddrv + .import _telestrat_240_200_2_tgi + +.rodata + +_tgi_static_stddrv := _telestrat_240_200_2_tgi diff --git a/libsrc/telestrat/write.s b/libsrc/telestrat/write.s index 30eac9532..6498283fb 100644 --- a/libsrc/telestrat/write.s +++ b/libsrc/telestrat/write.s @@ -17,7 +17,7 @@ sta ptr2 txa eor #$FF - sta ptr2+1 ; Remember -count-1 + sta ptr2+1 ; remember -count-1 jsr popptr1 ; get buf jsr popax ; get fd and discard @@ -30,7 +30,7 @@ next: cmp #1 beq L1 - ; Here it's a file opened + ; here it's a file opened lda ptr1 sta PTR_READ_DEST lda ptr1+1 @@ -38,6 +38,16 @@ next: lda ptr3 ldy ptr3+1 BRK_TELEMON XFWRITE + ; compute nb of bytes written + + + lda PTR_READ_DEST+1 + sec + sbc ptr1+1 + tax + lda PTR_READ_DEST + sec + sbc ptr1 rts @@ -48,23 +58,23 @@ L1: inc ptr2 L2: ldy #0 lda (ptr1),y tax - cpx #$0A ; Check for \n + cpx #$0A ; check for \n bne L3 - BRK_TELEMON XWR0 ; Macro send char to screen (channel 0 in telemon terms) - lda #$0D ; return to the beggining of the line - BRK_TELEMON XWR0 ; Macro ; + BRK_TELEMON XWR0 ; macro send char to screen (channel 0 in telemon terms) + lda #$0D ; return to the beggining of the line + BRK_TELEMON XWR0 ; macro ldx #$0D L3: - BRK_TELEMON XWR0 ; Macro + BRK_TELEMON XWR0 ; macro inc ptr1 bne L1 inc ptr1+1 jmp L1 -; No error, return count + ; No error, return count L9: lda ptr3 ldx ptr3+1 diff --git a/libsrc/tgi/tgi-kernel.s b/libsrc/tgi/tgi-kernel.s index ed65760af..3a388b6dc 100644 --- a/libsrc/tgi/tgi-kernel.s +++ b/libsrc/tgi/tgi-kernel.s @@ -6,7 +6,6 @@ .import tgi_libref .importzp ptr1 - .interruptor tgi_irq ; Export as IRQ handler .include "tgi-kernel.inc" .include "tgi-error.inc" @@ -81,7 +80,6 @@ tgi_line: jmp $0000 tgi_bar: jmp $0000 tgi_textstyle: jmp $0000 tgi_outtext: jmp $0000 -tgi_irq: .byte $60, $00, $00 ; RTS plus two dummy bytes ; Driver header signature .rodata @@ -144,20 +142,13 @@ _tgi_install: dex bpl @L3 -; Install the IRQ vector if the driver needs it. - - lda tgi_irq+2 ; Check high byte of IRQ vector - beq @L4 ; Jump if vector invalid - lda #$4C ; Jump opcode - sta tgi_irq ; Activate IRQ routine - ; Initialize some other variables lda #$00 -@L4: ldx #csize-1 -@L5: sta cstart,x ; Clear error/mode/curx/cury/... + ldx #csize-1 +@L4: sta cstart,x ; Clear error/mode/curx/cury/... dex - bpl @L5 + bpl @L4 rts @@ -206,9 +197,6 @@ _tgi_uninstall: jsr tgi_uninstall ; Allow the driver to clean up - lda #$60 ; RTS opcode - sta tgi_irq ; Disable IRQ entry point - ; Clear driver pointer and error code tgi_clear_ptr: diff --git a/libsrc/vic20/emd/vic20-georam.s b/libsrc/vic20/emd/vic20-georam.s new file mode 100755 index 000000000..a960e9a1a --- /dev/null +++ b/libsrc/vic20/emd/vic20-georam.s @@ -0,0 +1,352 @@ +; +; Extended memory driver for the GEORAM cartridge through the masC=erade +; c64 cartridge adapter. Driver works without problems when statically +; linked. +; +; Marco van den Heuvel, 2018-03-18 +; + + .include "zeropage.inc" + + .include "em-kernel.inc" + .include "em-error.inc" + + + .macpack generic + .macpack module + + +; ------------------------------------------------------------------------ +; Header. Includes jump table + + module_header _vic20_georam_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 + +; ------------------------------------------------------------------------ +; Constants + +GR_WINDOW = $9800 ; Address of GEORAM window +GR_PAGE_LO = $9CFE ; Page register low +GR_PAGE_HI = $9CFF ; Page register high + +; ------------------------------------------------------------------------ +; Data. + +.data + +pagecount: .res 2 ; Number of available pages + +.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: + ldx GR_WINDOW + cpx GR_WINDOW + bne @notpresent + inc GR_WINDOW + cpx GR_WINDOW + beq @notpresent + + lda #4 + jsr check + cpy GR_WINDOW + beq @has64k + lda #8 + jsr check + cpy GR_WINDOW + beq @has128k + lda #16 + jsr check + cpy GR_WINDOW + beq @has256k + lda #32 + jsr check + cpy GR_WINDOW + beq @has512k + lda #64 + jsr check + cpy GR_WINDOW + beq @has1024k + lda #128 + jsr check + cpy GR_WINDOW + beq @has2048k + ldx #>16384 + bne @setok + +@has64k: + ldx #>256 + bne @setok +@has128k: + ldx #>512 + bne @setok +@has256k: + ldx #>1024 + bne @setok +@has512k: + ldx #>2048 + bne @setok +@has1024k: + ldx #>4096 + bne @setok +@has2048k: + ldx #>8192 + bne @setok + +@notpresent: + lda #<EM_ERR_NO_DEVICE + ldx #>EM_ERR_NO_DEVICE + rts + +@setok: + lda #0 + sta pagecount + stx pagecount+1 + lda #<EM_ERR_OK + ldx #>EM_ERR_OK + rts + +check: + ldx #0 + stx GR_PAGE_LO + stx GR_PAGE_HI + ldy GR_WINDOW + iny + sta GR_PAGE_HI + sty GR_WINDOW + ldx #0 + stx GR_PAGE_HI +; 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 pagecount + ldx pagecount+1 + rts + +; ------------------------------------------------------------------------ +; USE: Tell the driver that the window is now associated with a given page. +; The GeoRAM cartridge does not copy but actually map the window, so USE is +; identical to MAP. + +USE = MAP + +; ------------------------------------------------------------------------ +; 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 tmp1 + txa + asl tmp1 + rol a + asl tmp1 + rol a + + sta GR_PAGE_HI + lda tmp1 + lsr a + lsr a + sta GR_PAGE_LO + + lda #<GR_WINDOW + ldx #>GR_WINDOW + +; Use the RTS from COMMIT below to save a precious byte of storage + +; ------------------------------------------------------------------------ +; COMMIT: Commit changes in the memory window to extended storage. + +COMMIT: 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: + jsr setup + +; Setup is: +; +; - ptr1 contains the struct pointer +; - ptr2 contains the linear memory buffer +; - ptr3 contains -(count-1) +; - tmp1 contains the low page register value +; - tmp2 contains the high page register value +; - X contains the page offset +; - Y contains zero + + jmp @L5 + +@L1: lda GR_WINDOW,x + sta (ptr2),y + iny + bne @L2 + inc ptr2+1 +@L2: inx + beq @L4 + +; Bump count and repeat + +@L3: inc ptr3 + bne @L1 + inc ptr3+1 + bne @L1 + rts + +; Bump page register + +@L4: inc tmp1 ; Bump low page register + bit tmp1 ; Check for overflow in bit 6 + bvc @L6 ; Jump if no overflow + inc tmp2 +@L5: lda tmp2 + sta GR_PAGE_HI +@L6: lda tmp1 + sta GR_PAGE_LO + jmp @L3 + +; ------------------------------------------------------------------------ +; 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: + jsr setup + +; Setup is: +; +; - ptr1 contains the struct pointer +; - ptr2 contains the linear memory buffer +; - ptr3 contains -(count-1) +; - tmp1 contains the low page register value +; - tmp2 contains the high page register value +; - X contains the page offset +; - Y contains zero + + jmp @L5 + +@L1: lda (ptr2),y + sta GR_WINDOW,x + iny + bne @L2 + inc ptr2+1 +@L2: inx + beq @L4 + +; Bump count and repeat + +@L3: inc ptr3 + bne @L1 + inc ptr3+1 + bne @L1 + rts + +; Bump page register + +@L4: inc tmp1 ; Bump low page register + bit tmp1 ; Check for overflow in bit 6 + bvc @L6 ; Jump if no overflow + inc tmp2 +@L5: lda tmp2 + sta GR_PAGE_HI +@L6: lda tmp1 + sta GR_PAGE_LO + jmp @L3 + +; ------------------------------------------------------------------------ +; Helper function for COPYFROM and COPYTO: Store the pointer to the request +; structure and prepare data for the copy + +setup: sta ptr1 + stx ptr1+1 ; Save passed pointer + +; Get the page number from the struct and adjust it so that it may be used +; with the hardware. That is: lower 6 bits in tmp1, high bits in tmp2. + + ldy #EM_COPY::PAGE+1 + lda (ptr1),y + sta tmp2 + dey + lda (ptr1),y + asl a + rol tmp2 + asl a + rol tmp2 + lsr a + lsr a + sta tmp1 + +; Get the buffer pointer into ptr2 + + ldy #EM_COPY::BUF + lda (ptr1),y + sta ptr2 + iny + lda (ptr1),y + sta ptr2+1 + +; Get the count, calculate -(count-1) and store it into ptr3 + + ldy #EM_COPY::COUNT + lda (ptr1),y + eor #$FF + sta ptr3 + iny + lda (ptr1),y + eor #$FF + sta ptr3+1 + +; Get the page offset into X and clear Y + + ldy #EM_COPY::OFFS + lda (ptr1),y + tax + ldy #$00 + +; Done + + rts + + diff --git a/libsrc/vic20/emd/vic20-rama.s b/libsrc/vic20/emd/vic20-rama.s new file mode 100644 index 000000000..a48959c13 --- /dev/null +++ b/libsrc/vic20/emd/vic20-rama.s @@ -0,0 +1,258 @@ +; +; Extended memory driver for the VIC20 $A000-$BFFF RAM. Driver works without +; problems when statically linked. +; +; Marco van den Heuvel, 2018-03-16 +; + + .include "zeropage.inc" + + .include "em-kernel.inc" + .include "em-error.inc" + + + .macpack generic + .macpack module + + +; ------------------------------------------------------------------------ +; Header. Includes jump table + + module_header _vic20_rama_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 + +; ------------------------------------------------------------------------ +; Constants + +BASE = $A000 +PAGES = ($C000 - BASE) / 256 + +; ------------------------------------------------------------------------ +; Data. + +.bss +curpage: .res 1 ; Current page number +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: + lda $A000 ; see what is at address $A000 + inc $A000 ; see if it can be changed + cmp $A000 ; did it stick ? + beq nomem + dec $A000 + + ldx #$FF + stx curpage ; Invalidate the current page + inx ; X = 0 + txa ; A = X = EM_ERR_OK + rts + +nomem: ldx #>EM_ERR_NO_DEVICE + lda #<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 #<PAGES + ldx #>PAGES + 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 + + clc + adc #>BASE + sta ptr1+1 + ldy #$00 + sty ptr1 + + lda #<window + sta ptr2 + lda #>window + sta ptr2+1 + +; Transfer one page + + jsr transfer ; Transfer one page + +; Return the memory window + + lda #<window + ldx #>window ; Return the window address + rts + +; ------------------------------------------------------------------------ +; USE: Tell the driver that the window is now associated with a given page. + +USE: sta curpage ; Remember the page + 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 + bmi done ; Jump if no page mapped + + clc + adc #>BASE + sta ptr2+1 + ldy #$00 + sty ptr2 + + lda #<window + sta ptr1 + lda #>window + sta ptr1+1 + +; Transfer one page. Y must be zero on entry + +transfer: + +; Unroll the following loop + +loop: .repeat 8 + lda (ptr1),y + sta (ptr2),y + iny + .endrepeat + + bne loop + +; Done + +done: 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 ptr3 + stx ptr3+1 ; Save the passed em_copy pointer + + ldy #EM_COPY::OFFS + lda (ptr3),y + sta ptr1 + ldy #EM_COPY::PAGE + lda (ptr3),y + clc + adc #>BASE + sta ptr1+1 ; From + + ldy #EM_COPY::BUF + lda (ptr3),y + sta ptr2 + iny + lda (ptr3),y + sta ptr2+1 ; To + +common: ldy #EM_COPY::COUNT+1 + lda (ptr3),y ; Get number of pages + beq @L2 ; Skip if no full pages + sta tmp1 + +; Copy full pages allowing interrupts after each page copied + + ldy #$00 +@L1: jsr transfer + inc ptr1+1 + inc ptr2+1 + dec tmp1 + bne @L1 + +; Copy the remainder of the page + +@L2: ldy #EM_COPY::COUNT + lda (ptr3),y ; Get bytes in last page + beq @L4 + tax + +; Transfer the bytes in the last page + + ldy #$00 +@L3: lda (ptr1),y + sta (ptr2),y + iny + dex + bne @L3 + +; Done + +@L4: 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 ptr3 + stx ptr3+1 ; Save the passed em_copy pointer + + ldy #EM_COPY::OFFS + lda (ptr3),y + sta ptr2 + ldy #EM_COPY::PAGE + lda (ptr3),y + clc + adc #>BASE + sta ptr2+1 ; To + + ldy #EM_COPY::BUF + lda (ptr3),y + sta ptr1 + iny + lda (ptr3),y + sta ptr1+1 ; From + + jmp common + diff --git a/libsrc/vic20/get_tv.s b/libsrc/vic20/get_tv.s index 7182c0df7..9194a2c55 100644 --- a/libsrc/vic20/get_tv.s +++ b/libsrc/vic20/get_tv.s @@ -1,12 +1,11 @@ ; -; Stefan Haubenthal, 2004-10-07 -; Based on code from Pu-239 +; Stefan Haubenthal, 2018-04-10 +; Based on code by Mike ; ; unsigned char get_tv (void); ; /* Return the video mode the machine is using */ ; - .include "vic20.inc" .include "get_tv.inc" ;-------------------------------------------------------------------------- @@ -14,18 +13,13 @@ .proc _get_tv -NTSC_LINES = 261 ; detect the system lda #TV::NTSC tax -@L0: ldy VIC_HLINE - cpy #1 - bne @L0 ; wait for line 1 -@L1: ldy VIC_HLINE - beq @L2 ; line 0 reached -> NTSC - cpy #NTSC_LINES/2+2 - bne @L1 + ldy $EDE4 ; VIC init table + cpy #5 + beq @L0 lda #TV::PAL -@L2: rts ; system detected: 0 for NTSC, 1 for PAL +@L0: rts ; system detected: 0 for NTSC, 1 for PAL .endproc diff --git a/libsrc/vic20/joy/vic20-ptvjoy.s b/libsrc/vic20/joy/vic20-ptvjoy.s index 3b1db402a..496653e9d 100644 --- a/libsrc/vic20/joy/vic20-ptvjoy.s +++ b/libsrc/vic20/joy/vic20-ptvjoy.s @@ -36,12 +36,10 @@ .addr UNINSTALL .addr COUNT .addr READ - .addr 0 ; IRQ entry unused ; ------------------------------------------------------------------------ ; Constants -VIA1_PRB := VIA1 ; User port register JOY_COUNT = 3 ; Number of joysticks we support @@ -92,13 +90,13 @@ joy1: lda #$7F ; mask for VIA2 JOYBIT: sw3 ldy VIA2_DDRB ; remember the date of DDRB sta VIA2_DDRB ; set JOYBITS on this VIA for input - lda VIA2_JOY ; read JOYBIT: sw3 + lda VIA2_PB ; read JOYBIT: sw3 sty VIA2_DDRB ; restore the state of DDRB asl ; Shift sw3 into carry ldy VIA1_DDRA ; remember the state of DDRA stx VIA1_DDRA ; set JOYBITS on this VIA for input - lda VIA1_JOY ; read JOYBITS: sw0,sw1,sw2,sw4 + lda VIA1_PA1 ; read JOYBITS: sw0,sw1,sw2,sw4 sty VIA1_DDRA ; restore the state of DDRA cli ; necessary? @@ -128,9 +126,9 @@ joy2: lda #%10000000 ; via port B Data-Direction bne joy3 lda #$80 ; via port B read/write - sta VIA1_PRB ; (output one at PB7) + sta VIA1_PB ; (output one at PB7) - lda VIA1_PRB ; via port B read/write + lda VIA1_PB ; via port B read/write and #$1F ; get bit 4-0 (PB4-PB0) eor #$1F rts @@ -138,13 +136,13 @@ joy2: lda #%10000000 ; via port B Data-Direction ; Read joystick 3 joy3: lda #$00 ; via port B read/write - sta VIA1_PRB ; (output zero at PB7) + sta VIA1_PB ; (output zero at PB7) - lda VIA1_PRB ; via port B read/write + lda VIA1_PB ; via port B read/write and #$0F ; get bit 3-0 (PB3-PB0) sta tmp1 ; joy 4 directions - lda VIA1_PRB ; via port B read/write + lda VIA1_PB ; via port B read/write and #%00100000 ; get bit 5 (PB5) lsr ora tmp1 diff --git a/libsrc/vic20/joy/vic20-stdjoy.s b/libsrc/vic20/joy/vic20-stdjoy.s index 67299cc1a..ee8dc93d7 100644 --- a/libsrc/vic20/joy/vic20-stdjoy.s +++ b/libsrc/vic20/joy/vic20-stdjoy.s @@ -36,7 +36,6 @@ .addr UNINSTALL .addr COUNT .addr READ - .addr 0 ; IRQ entry unused ; ------------------------------------------------------------------------ ; Constants @@ -91,13 +90,13 @@ READ: lda #$7F ; mask for VIA2 JOYBIT: sw3 ldy VIA2_DDRB ; remember the date of DDRB sta VIA2_DDRB ; set JOYBITS on this VIA for input - lda VIA2_JOY ; read JOYBIT: sw3 + lda VIA2_PB ; read JOYBIT: sw3 sty VIA2_DDRB ; restore the state of DDRB asl ; Shift sw3 into carry ldy VIA1_DDRA ; remember the state of DDRA stx VIA1_DDRA ; set JOYBITS on this VIA for input - lda VIA1_JOY ; read JOYBITS: sw0,sw1,sw2,sw4 + lda VIA1_PA1 ; read JOYBITS: sw0,sw1,sw2,sw4 sty VIA1_DDRA ; restore the state of DDRA cli ; necessary? diff --git a/libsrc/vic20/libref.s b/libsrc/vic20/libref.s index e4afa7eb1..468c540f1 100644 --- a/libsrc/vic20/libref.s +++ b/libsrc/vic20/libref.s @@ -3,6 +3,8 @@ ; .export joy_libref + .export em_libref .import _exit joy_libref := _exit +em_libref := _exit diff --git a/libsrc/zlib/inflatemem.s b/libsrc/zlib/inflatemem.s index 27802fbff..bc89f2016 100644 --- a/libsrc/zlib/inflatemem.s +++ b/libsrc/zlib/inflatemem.s @@ -1,5 +1,5 @@ ; -; 2017-02-12, Piotr Fusik +; 2017-11-07, Piotr Fusik ; ; unsigned __fastcall__ inflatemem (char* dest, const char* source); ; @@ -103,7 +103,7 @@ inflate_blockLoop: ; ldy #0 sty getBit_buffer ; ignore bits until byte boundary jsr getWord ; skip the length we don't need - jsr getWord ; get the two's complement length + jsr getWord ; get the one's complement length sta inflateStored_pageCounter bcs inflateStored_firstByte ; jmp inflateStored_copyByte: @@ -332,7 +332,7 @@ inflateDynamic_storeControl: ; Build Huffman trees basing on code lengths (in bits) ; stored in the *SymbolCodeLength arrays buildHuffmanTree: -; Clear nBitCode_totalCount, nBitCode_literalCount, nBitCode_controlCount +; Clear nBitCode_literalCount, nBitCode_controlCount tya ; lda #0 buildHuffmanTree_clear: @@ -344,22 +344,23 @@ buildHuffmanTree_clear: buildHuffmanTree_countCodeLengths: ldx literalSymbolCodeLength,y inc nBitCode_literalCount,x - inc nBitCode_totalCount,x + bne buildHuffmanTree_notAllLiterals + stx allLiteralsCodeLength +buildHuffmanTree_notAllLiterals: cpy #CONTROL_SYMBOLS bcs buildHuffmanTree_noControlSymbol ldx controlSymbolCodeLength,y inc nBitCode_controlCount,x - inc nBitCode_totalCount,x buildHuffmanTree_noControlSymbol: iny bne buildHuffmanTree_countCodeLengths ; Calculate offsets of symbols sorted by code length ; lda #0 - ldx #$100-3*TREE_SIZE + ldx #$100-4*TREE_SIZE buildHuffmanTree_calculateOffsets: - sta nBitCode_literalOffset+3*TREE_SIZE-$100,x + sta nBitCode_literalOffset+4*TREE_SIZE-$100,x clc - adc nBitCode_literalCount+3*TREE_SIZE-$100,x + adc nBitCode_literalCount+4*TREE_SIZE-$100,x inx bne buildHuffmanTree_calculateOffsets ; Put symbols in their place in the sorted array @@ -396,26 +397,40 @@ fetchCode_nextBit: jsr getBit rol a inx + bcs fetchCode_ge256 +; are all 256 literal codes of this length? + cpx allLiteralsCodeLength + beq fetchCode_allLiterals +; is it literal code of length X? sec - sbc nBitCode_totalCount,x - bcs fetchCode_nextBit -; clc - adc nBitCode_controlCount,x - bcs fetchCode_control + sbc nBitCode_literalCount,x + bcs fetchCode_notLiteral +; literal code ; clc adc nBitCode_literalOffset,x tax lda codeToLiteralSymbol,x +fetchCode_allLiterals: clc rts -fetchCode_control: +; code >= 256, must be control +fetchCode_ge256: ; sec - adc nBitCode_controlOffset-1,x + sbc nBitCode_literalCount,x + sec +; is it control code of length X? +fetchCode_notLiteral: +; sec + sbc nBitCode_controlCount,x + bcs fetchCode_nextBit +; control code +; clc + adc nBitCode_controlOffset,x tax - lda codeToControlSymbol-1,x + lda codeToControlSymbol,x and #$1f ; make distance symbols zero-based tax - sec +; sec rts ; Read A minus 1 bits, but no more than 8 @@ -517,16 +532,16 @@ controlSymbolCodeLength: ; Huffman trees. nBitCode_clearFrom: -nBitCode_totalCount: - .res 2*TREE_SIZE nBitCode_literalCount: - .res TREE_SIZE + .res 2*TREE_SIZE nBitCode_controlCount: .res 2*TREE_SIZE nBitCode_literalOffset: - .res TREE_SIZE + .res 2*TREE_SIZE nBitCode_controlOffset: .res 2*TREE_SIZE +allLiteralsCodeLength: + .res 1 codeToLiteralSymbol: .res 256 diff --git a/samples/Makefile b/samples/Makefile index 59841d655..8bb6d25ae 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -4,8 +4,8 @@ # This Makefile requires GNU make # -# Run 'make SYS=<target>' or set a SYS env -# var to build for another target system. +# Run 'make SYS=<target>'; or, set a SYS env. +# var. to build for another target system. SYS ?= c64 ifneq ($(shell echo),) @@ -41,13 +41,14 @@ ifneq ($(filter disk samples.%,$(MAKECMDGOALS)),) MOU := $(wildcard $(TARGET_PATH)/$(SYS)/drv/mou/*) TGI := $(wildcard $(TARGET_PATH)/$(SYS)/drv/tgi/*) - # This one comes with VICE + # This one comes with the VICE emulator. + # See http://vice-emu.sourceforge.net/ C1541 ?= c1541 - # For this one see http://applecommander.sourceforge.net/ + # For this one, see https://applecommander.github.io/ AC ?= ac.jar - # For this one see http://www.horus.com/~hias/atari/ + # For this one, see http://www.horus.com/~hias/atari/ DIR2ATR ?= dir2atr DISK_c64 = samples.d64 @@ -59,6 +60,8 @@ endif # -------------------------------------------------------------------------- # System-dependent settings +# For convenience, these groups and lines are sorted alphabetically, first +# by target-machine group, then by mission, then by program and sub-target. # The Apple machines need the start address adjusted when using TGI LDFLAGS_mandelbrot_apple2 = --start-addr 0x4000 @@ -94,15 +97,19 @@ LDFLAGS_tgidemo_atarixl = --start-addr 0x4000 $(AS) $(<:.c=.s) .s.o: - $(AS) $(AFLAGS) -t $(SYS) $< + $(AS) $(ASFLAGS) -t $(SYS) $< .PRECIOUS: %.o .o: - $(LD) $(LDFLAGS_$(@F)_$(SYS)) -o $@ -t $(SYS) -m $@.map $^ $(SYS).lib +ifeq ($(SYS),vic20) + $(LD) $(LDFLAGS_$(@F)_$(SYS)) $(LDFLAGS) -o $@ -C vic20-32k.cfg -m $@.map $^ $(SYS).lib +else + $(LD) $(LDFLAGS_$(@F)_$(SYS)) $(LDFLAGS) -o $@ -t $(SYS) -m $@.map $^ $(SYS).lib +endif # -------------------------------------------------------------------------- -# List of executables +# Lists of executables EXELIST_c64 = \ ascii \ @@ -150,6 +157,13 @@ EXELIST_atarixl = $(EXELIST_atari) EXELIST_atari2600 = \ atari2600hello +# Unlisted targets will try to build everything. +# That lets us learn what they cannot build, and what settings +# we need to use for programs that can be built and run. +ifndef EXELIST_$(SYS) +EXELIST_$(SYS) := ${patsubst %.c,%,$(wildcard *.c)} +endif + # -------------------------------------------------------------------------- # Rules to make the binaries and the disk @@ -164,10 +178,10 @@ all: # overlay file-names are shortenned to fit the Atari's 8.3-character limit. multdemo: multidemo.o - $(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(SYS).lib + $(LD) $(LDFLAGS) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(SYS).lib ovrldemo: overlaydemo.o - $(LD) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(SYS).lib + $(LD) $(LDFLAGS) -o $@ -C $(SYS)-overlay.cfg -m $@.map $^ $(SYS).lib OVERLAYLIST := $(foreach I,1 2 3,multdemo.$I ovrldemo.$I) @@ -188,15 +202,15 @@ samples.d64: samples $(foreach file,$(EMD) $(MOU) $(TGI),$(D64_WRITE_recipe)) # -------------------------------------------------------------------------- -# Rule to make an Apple II disk with all samples. Needs the Apple Commander -# program available at http://applecommander.sourceforge.net/ and a template -# disk named 'prodos.dsk'. +# Rule to make an Apple II disk with all samples. Needs the AppleCommander +# program, available at https://applecommander.github.io/, and a template disk +# named 'prodos.dsk'. define DSK_WRITE_BIN_recipe $(if $(findstring BF00,$(LDFLAGS_$(notdir $(file))_$(SYS))), \ java -jar $(AC) -p $@ $(notdir $(file)).system sys <$(TARGET_PATH)/$(SYS)/util/loader.system) -java -jar $(AC) -cc65 $@ $(notdir $(file)) bin <$(file) +java -jar $(AC) -as $@ $(notdir $(file)) <$(file) endef # DSK_WRITE_BIN_recipe @@ -260,7 +274,7 @@ zip: # Clean-up rules mostlyclean: - @$(DEL) *.map *.o *.s 2>$(NULLDEV) + @$(DEL) *.lbl *.map *.o *.s 2>$(NULLDEV) clean: mostlyclean @$(DEL) $(EXELIST_$(SYS)) $(DISK_$(SYS)) 2>$(NULLDEV) diff --git a/samples/fire.c b/samples/fire.c index 44eb07c88..40eff0707 100644 --- a/samples/fire.c +++ b/samples/fire.c @@ -17,6 +17,7 @@ #include <string.h> /* for memset */ #include <time.h> #include <conio.h> +#include <cbm.h> @@ -60,9 +61,9 @@ #ifdef DOVSYNC -# define waitvsync() while ((signed char)VIC.ctrl1 >= 0) +# define WAITVSYNC() waitvsync() #else -# define waitvsync() +# define WAITVSYNC() #endif @@ -203,12 +204,12 @@ int main (void) while (!kbhit()) { /* Build page 1, then make it visible */ fire (SCREEN1); - waitvsync (); + WAITVSYNC (); outb (&VIC.addr, PAGE1); /* Build page 2, then make it visible */ fire (SCREEN2); - waitvsync (); + WAITVSYNC (); outb (&VIC.addr, PAGE2); /* Count frames */ diff --git a/samples/geos/geosver.c b/samples/geos/geosver.c new file mode 100644 index 000000000..1402d148e --- /dev/null +++ b/samples/geos/geosver.c @@ -0,0 +1,62 @@ +#include <geos.h> +#include <conio.h> + +// Let's define the window we're operating +struct window wholeScreen = {0, SC_PIX_HEIGHT-1, 0, SC_PIX_WIDTH-1}; + + +void main (void) +{ + unsigned char os = get_ostype(); + unsigned char *machine = NULL; + unsigned char *version = NULL; + unsigned char good = 1; + + SetPattern(0); + InitDrawWindow(&wholeScreen); + Rectangle(); + gotoxy(0, 4); + if (os == GEOS4) { + machine = "plus4"; + version = "GEOS v3.5"; + } else { + if ((os & GEOS128) == GEOS128) { + machine = "c128"; + } else { + machine = "c64"; + } + os &= 0x7f; + if (os == GEOS_V10) { + version = "GEOS v1.0"; + } else if (os == GEOS_V11) { + version = "GEOS v1.1"; + } else if (os == GEOS_V12) { + version = "GEOS v1.2"; + } else if (os == GEOS_V13) { + version = "GEOS v1.3"; + } else if (os == GEOS_V15) { + version = "GEOS v1.5"; + } else if (os == GEOS_V20) { + version = "GEOS v2.0"; + } else if (os == MEGAPATCH3) { + version = "MegaPatch 3"; + } else if (os == GATEWAY) { + version = "GateWay"; + } else if ((os & WHEELS) == WHEELS) { + version = "Wheels"; + } else { + version = "Unknown GEOS version"; + good = 0; + } + } + + if (good) { + cprintf("%s (%s)", version, machine); + } else { + cprintf("%s (%s) (%d)", version, machine, os); + } + + Sleep(10*50); + + return; +} diff --git a/samples/geos/geosverres.grc b/samples/geos/geosverres.grc new file mode 100644 index 000000000..9a3d72a26 --- /dev/null +++ b/samples/geos/geosverres.grc @@ -0,0 +1,8 @@ + +; this is the resource file for geosver.c, a GEOS application example + +HEADER APPLICATION "geosver" "GEOSver" "V1.0" { +dostype USR +author "Marco van den Heuvel" +info "This is a C prog compiled with cc65 and GEOSLib." +} diff --git a/samples/tgidemo.c b/samples/tgidemo.c index d8c2a6f50..6f3b86abc 100644 --- a/samples/tgidemo.c +++ b/samples/tgidemo.c @@ -49,8 +49,9 @@ static void CheckError (const char* S) +#if DYN_DRV static void DoWarning (void) -/* Warn the user that the TGI driver is needed for this program */ +/* Warn the user that the dynamic TGI driver is needed for this program */ { printf ("Warning: This program needs the TGI\n" "driver on disk! Press 'y' if you have\n" @@ -58,8 +59,9 @@ static void DoWarning (void) if (tolower (cgetc ()) != 'y') { exit (EXIT_SUCCESS); } - printf ("Ok. Please wait patiently...\n"); + printf ("OK. Please wait patiently...\n"); } +#endif diff --git a/src/.gitignore b/src/.gitignore index d2b9fe751..a2c8bb5d4 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -2,5 +2,7 @@ ipch/ *.suo *.sdf *.opensdf +*.VC.db +*.VC.VC.opendb *.vcxproj.filters *.vcxproj.user diff --git a/src/Makefile b/src/Makefile index 8b41ceb9c..524651428 100644 --- a/src/Makefile +++ b/src/Makefile @@ -55,7 +55,7 @@ endif ifdef GIT_SHA $(info GIT_SHA: $(GIT_SHA)) else - GIT_SHA := $(shell git rev-parse --short HEAD 2>$(NULLDEV)) + GIT_SHA := $(shell git rev-parse --short HEAD 2>$(NULLDEV) || svnversion 2>$(NULLDEV)) ifneq ($(words $(GIT_SHA)),1) GIT_SHA := N/A $(info GIT_SHA: N/A) diff --git a/src/ar65.vcxproj b/src/ar65.vcxproj index b077134ce..003a5fa69 100644 --- a/src/ar65.vcxproj +++ b/src/ar65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/ca65.vcxproj b/src/ca65.vcxproj index 4e02fa2a9..fb7cf2e26 100644 --- a/src/ca65.vcxproj +++ b/src/ca65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/ca65/instr.c b/src/ca65/instr.c index 53d3573a6..37217203a 100644 --- a/src/ca65/instr.c +++ b/src/ca65/instr.c @@ -758,7 +758,7 @@ static const struct { { "BNZ", AMSW16_BRA, 0x07, 0, PutSweet16Branch }, { "BP", AMSW16_BRA, 0x04, 0, PutSweet16Branch }, { "BR", AMSW16_BRA, 0x01, 0, PutSweet16Branch }, - { "BS", AMSW16_BRA, 0x0B, 0, PutSweet16Branch }, + { "BS", AMSW16_BRA, 0x0C, 0, PutSweet16Branch }, { "BZ", AMSW16_BRA, 0x06, 0, PutSweet16Branch }, { "CPR", AMSW16_REG, 0xD0, 0, PutSweet16 }, { "DCR", AMSW16_REG, 0xF0, 0, PutSweet16 }, diff --git a/src/cc65.vcxproj b/src/cc65.vcxproj index 70f43dc73..12573e862 100644 --- a/src/cc65.vcxproj +++ b/src/cc65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/cc65/codegen.c b/src/cc65/codegen.c index dfc06fccc..9e5102728 100644 --- a/src/cc65/codegen.c +++ b/src/cc65/codegen.c @@ -40,6 +40,7 @@ /* common */ #include "check.h" #include "cpu.h" +#include "inttypes.h" #include "strbuf.h" #include "xmalloc.h" #include "xsprintf.h" @@ -92,7 +93,7 @@ static void CheckLocalOffs (unsigned Offs) -static const char* GetLabelName (unsigned Flags, unsigned long Label, long Offs) +static const char* GetLabelName (unsigned Flags, uintptr_t Label, long Offs) { static char Buf [256]; /* Label name */ @@ -119,7 +120,7 @@ static const char* GetLabelName (unsigned Flags, unsigned long Label, long Offs) case CF_ABSOLUTE: /* Absolute address */ - xsprintf (Buf, sizeof (Buf), "$%04X", (int)((Label+Offs) & 0xFFFF)); + xsprintf (Buf, sizeof (Buf), "$%04X", (unsigned)((Label+Offs) & 0xFFFF)); break; case CF_REGVAR: @@ -729,7 +730,7 @@ void g_getimmed (unsigned Flags, unsigned long Val, long Offs) -void g_getstatic (unsigned flags, unsigned long label, long offs) +void g_getstatic (unsigned flags, uintptr_t label, long offs) /* Fetch an static memory cell into the primary register */ { /* Create the correct label name */ @@ -1008,7 +1009,7 @@ void g_leavariadic (int Offs) -void g_putstatic (unsigned flags, unsigned long label, long offs) +void g_putstatic (unsigned flags, uintptr_t label, long offs) /* Store the primary register into the specified static memory cell */ { /* Create the correct label name */ @@ -1584,7 +1585,7 @@ void g_addlocal (unsigned flags, int offs) -void g_addstatic (unsigned flags, unsigned long label, long offs) +void g_addstatic (unsigned flags, uintptr_t label, long offs) /* Add a static variable to ax */ { unsigned L; @@ -1634,7 +1635,7 @@ void g_addstatic (unsigned flags, unsigned long label, long offs) -void g_addeqstatic (unsigned flags, unsigned long label, long offs, +void g_addeqstatic (unsigned flags, uintptr_t label, long offs, unsigned long val) /* Emit += for a static variable */ { @@ -1857,7 +1858,7 @@ void g_addeqind (unsigned flags, unsigned offs, unsigned long val) -void g_subeqstatic (unsigned flags, unsigned long label, long offs, +void g_subeqstatic (unsigned flags, uintptr_t label, long offs, unsigned long val) /* Emit -= for a static variable */ { @@ -2093,7 +2094,7 @@ void g_addaddr_local (unsigned flags attribute ((unused)), int offs) -void g_addaddr_static (unsigned flags, unsigned long label, long offs) +void g_addaddr_static (unsigned flags, uintptr_t label, long offs) /* Add the address of a static variable to ax */ { /* Create the correct label name */ @@ -4276,7 +4277,7 @@ void g_initstatic (unsigned InitLabel, unsigned VarLabel, unsigned Size) g_getimmed (CF_STATIC, InitLabel, 0); AddCodeLine ("jsr pushax"); g_getimmed (CF_INT | CF_UNSIGNED | CF_CONST, Size, 0); - AddCodeLine ("jsr %s", GetLabelName (CF_EXTERNAL, (unsigned long) "memcpy", 0)); + AddCodeLine ("jsr %s", GetLabelName (CF_EXTERNAL, (uintptr_t) "memcpy", 0)); } } diff --git a/src/cc65/codegen.h b/src/cc65/codegen.h index 4ad375618..bbad0f125 100644 --- a/src/cc65/codegen.h +++ b/src/cc65/codegen.h @@ -40,6 +40,7 @@ /* common */ #include "coll.h" +#include "inttypes.h" /* cc65 */ #include "segments.h" @@ -266,7 +267,7 @@ void g_restore_regvars (int StackOffs, int RegOffs, unsigned Bytes); void g_getimmed (unsigned Flags, unsigned long Val, long Offs); /* Load a constant into the primary register */ -void g_getstatic (unsigned Flags, unsigned long Label, long Offs); +void g_getstatic (unsigned Flags, uintptr_t Label, long Offs); /* Fetch an static memory cell into the primary register */ void g_getlocal (unsigned Flags, int Offs); @@ -293,7 +294,7 @@ void g_leavariadic (int Offs); -void g_putstatic (unsigned flags, unsigned long label, long offs); +void g_putstatic (unsigned flags, uintptr_t label, long offs); /* Store the primary register into the specified static memory cell */ void g_putlocal (unsigned Flags, int Offs, long Val); @@ -315,7 +316,7 @@ void g_putind (unsigned flags, unsigned offs); void g_addlocal (unsigned flags, int offs); /* Add a local variable to ax */ -void g_addstatic (unsigned flags, unsigned long label, long offs); +void g_addstatic (unsigned flags, uintptr_t label, long offs); /* Add a static variable to ax */ @@ -326,7 +327,7 @@ void g_addstatic (unsigned flags, unsigned long label, long offs); -void g_addeqstatic (unsigned flags, unsigned long label, long offs, +void g_addeqstatic (unsigned flags, uintptr_t label, long offs, unsigned long val); /* Emit += for a static variable */ @@ -336,7 +337,7 @@ void g_addeqlocal (unsigned flags, int offs, unsigned long val); void g_addeqind (unsigned flags, unsigned offs, unsigned long val); /* Emit += for the location with address in ax */ -void g_subeqstatic (unsigned flags, unsigned long label, long offs, +void g_subeqstatic (unsigned flags, uintptr_t label, long offs, unsigned long val); /* Emit -= for a static variable */ @@ -357,7 +358,7 @@ void g_subeqind (unsigned flags, unsigned offs, unsigned long val); void g_addaddr_local (unsigned flags, int offs); /* Add the address of a local variable to ax */ -void g_addaddr_static (unsigned flags, unsigned long label, long offs); +void g_addaddr_static (unsigned flags, uintptr_t label, long offs); /* Add the address of a static variable to ax */ diff --git a/src/cc65/coptstore.c b/src/cc65/coptstore.c index 56343c95b..b0dfe3b6d 100644 --- a/src/cc65/coptstore.c +++ b/src/cc65/coptstore.c @@ -380,48 +380,48 @@ unsigned OptStore5 (CodeSeg* S) ** sta something ** stx something-else ** -** and replace it by +** and, replace it by ** -** lda foo -** sta something ** lda bar ** sta something-else +** lda foo +** sta something ** -** if X is not used later. This replacement doesn't save any cycles or bytes, -** but it keeps the value of X, which may be reused later. +** if the new value of X is not used later. That replacement doesn't save any +** cycles or bytes; but, it keeps the old value of X, which may be reused later. */ { unsigned Changes = 0; + unsigned I = 0; /* Walk over the entries */ - unsigned I = 0; while (I < CS_GetEntryCount (S)) { - CodeEntry* L[4]; /* Get next entry */ L[0] = CS_GetEntry (S, I); /* Check for the sequence */ - if (L[0]->OPC == OP65_LDA && - !CS_RangeHasLabel (S, I+1, 3) && - CS_GetEntries (S, L+1, I+1, 3) && - L[1]->OPC == OP65_LDX && - L[2]->OPC == OP65_STA && - L[3]->OPC == OP65_STX && + if (L[0]->OPC == OP65_LDA && + !CS_RangeHasLabel (S, I+1, 3) && + CS_GetEntries (S, L+1, I+1, 3) && + L[1]->OPC == OP65_LDX && + L[2]->OPC == OP65_STA && + L[3]->OPC == OP65_STX && !RegXUsed (S, I+4)) { - CodeEntry* X; + CodeEntry* E = CS_GetEntry (S, I+1); - /* Insert the code after the sequence */ - X = NewCodeEntry (OP65_LDA, L[1]->AM, L[1]->Arg, 0, L[1]->LI); - CS_InsertEntry (S, X, I+4); - X = NewCodeEntry (OP65_STA, L[3]->AM, L[3]->Arg, 0, L[3]->LI); - CS_InsertEntry (S, X, I+5); + /* Move the high-byte code to the beginning of the sequence */ + CS_MoveEntry (S, I+1, I); + CS_MoveEntry (S, I+3, I+1); - /* Delete the old code */ - CS_DelEntry (S, I+3); - CS_DelEntry (S, I+1); + /* Change from the X register to the A register */ + CE_ReplaceOPC (E, OP65_LDA); + CE_ReplaceOPC (CS_GetEntry (S, I+1), OP65_STA); + + /* Move labels from the old first entry to the new first entry */ + CS_MoveLabels (S, CS_GetEntry (S, I+2), E); /* Remember, we had changes */ ++Changes; @@ -429,7 +429,6 @@ unsigned OptStore5 (CodeSeg* S) /* Next entry */ ++I; - } /* Return the number of changes made */ diff --git a/src/cc65/declare.c b/src/cc65/declare.c index a6b232905..19100781c 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -656,13 +656,16 @@ static SymEntry* ParseUnionDecl (const char* Name) /* Check for fields without a name */ if (Decl.Ident[0] == '\0') { /* In cc65 mode, we allow anonymous structs/unions within - ** a struct. + ** a union. */ if (IS_Get (&Standard) >= STD_CC65 && IsClassStruct (Decl.Type)) { /* This is an anonymous struct or union. Copy the fields ** into the current level. */ - CopyAnonStructFields (&Decl, 0); + FieldSize = CopyAnonStructFields (&Decl, 0); + if (FieldSize > UnionSize) { + UnionSize = FieldSize; + } } else { /* A non bit-field without a name is legal but useless */ diff --git a/src/cc65/expr.c b/src/cc65/expr.c index acfd95fed..43971caae 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -1,7 +1,7 @@ /* expr.c ** ** 1998-06-21, Ullrich von Bassewitz -** 2015-06-26, Greg King +** 2017-12-05, Greg King */ @@ -537,7 +537,7 @@ static void FunctionCall (ExprDesc* Expr) if (IsFuncPtr) { if (Func->WrappedCall) { - Warning("Calling a wrapped function via a pointer, wrapped-call will not be used"); + Warning ("Calling a wrapped function via a pointer, wrapped-call will not be used"); } /* If the function is not a fastcall function, load the pointer to @@ -731,7 +731,7 @@ static void Primary (ExprDesc* E) } else if ((Sym->Flags & SC_FUNC) == SC_FUNC) { /* Function */ E->Flags = E_LOC_GLOBAL | E_RTYPE_LVAL; - E->Name = (unsigned long) Sym->Name; + E->Name = (uintptr_t) Sym->Name; } else if ((Sym->Flags & SC_AUTO) == SC_AUTO) { /* Local variable. If this is a parameter for a variadic ** function, we have to add some address calculations, and the @@ -754,7 +754,7 @@ static void Primary (ExprDesc* E) /* Static variable */ if (Sym->Flags & (SC_EXTERN | SC_STORAGE)) { E->Flags = E_LOC_GLOBAL | E_RTYPE_LVAL; - E->Name = (unsigned long) Sym->Name; + E->Name = (uintptr_t) Sym->Name; } else { E->Flags = E_LOC_STATIC | E_RTYPE_LVAL; E->Name = Sym->V.Label; @@ -798,7 +798,7 @@ static void Primary (ExprDesc* E) Sym = AddGlobalSym (Ident, GetImplicitFuncType(), SC_EXTERN | SC_REF | SC_FUNC); E->Type = Sym->Type; E->Flags = E_LOC_GLOBAL | E_RTYPE_RVAL; - E->Name = (unsigned long) Sym->Name; + E->Name = (uintptr_t) Sym->Name; } else { /* Undeclared Variable */ Sym = AddLocalSym (Ident, type_int, SC_AUTO | SC_REF, 0); @@ -1308,7 +1308,7 @@ static void hie11 (ExprDesc *Expr) ** Since we don't have a name, invent one. */ ED_MakeConstAbs (Expr, 0, GetImplicitFuncType ()); - Expr->Name = (long) IllegalFunc; + Expr->Name = (uintptr_t) IllegalFunc; } /* Call the function */ FunctionCall (Expr); diff --git a/src/cc65/exprdesc.c b/src/cc65/exprdesc.c index 405c277a0..46377ac6b 100644 --- a/src/cc65/exprdesc.c +++ b/src/cc65/exprdesc.c @@ -44,7 +44,6 @@ #include "exprdesc.h" #include "stackptr.h" #include "symentry.h" -#include "exprdesc.h" @@ -361,7 +360,7 @@ void PrintExprDesc (FILE* F, ExprDesc* E) if (Sep != '(') { fputc (')', F); } - fprintf (F, "\nName: 0x%08lX\n", E->Name); + fprintf (F, "\nName: 0x%08lX\n", (unsigned long)E->Name); } diff --git a/src/cc65/exprdesc.h b/src/cc65/exprdesc.h index 99a17313e..e86534902 100644 --- a/src/cc65/exprdesc.h +++ b/src/cc65/exprdesc.h @@ -43,6 +43,7 @@ /* common */ #include "fp.h" #include "inline.h" +#include "inttypes.h" /* cc65 */ #include "asmcode.h" @@ -98,7 +99,7 @@ struct ExprDesc { struct SymEntry* Sym; /* Symbol table entry if known */ Type* Type; /* Type array of expression */ unsigned Flags; - unsigned long Name; /* Name or label number */ + uintptr_t Name; /* Name pointer or label number */ long IVal; /* Integer value if expression constant */ Double FVal; /* Floating point value */ struct Literal* LVal; /* Literal value */ diff --git a/src/cc65/main.c b/src/cc65/main.c index d3d298876..f8361f41c 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -986,6 +986,9 @@ int main (int argc, char* argv[]) case 's': IS_Set (&InlineStdFuncs, 1); break; + default: + UnknownOption (Arg); + break; } } break; diff --git a/src/cc65/pragma.c b/src/cc65/pragma.c index 25bc29d43..64ea4a1aa 100644 --- a/src/cc65/pragma.c +++ b/src/cc65/pragma.c @@ -525,7 +525,7 @@ static void WrappedCallPragma (StrBuf* B) /* Check if the name is valid */ if (Entry && Entry->Flags & SC_FUNC) { - PushWrappedCall(Entry, Val); + PushWrappedCall(Entry, (unsigned char) Val); Entry->Flags |= SC_REF; Entry->V.F.Func->Flags |= FD_CALL_WRAPPER; diff --git a/src/cc65/wrappedcall.c b/src/cc65/wrappedcall.c index 2d11245fd..18cb507ac 100644 --- a/src/cc65/wrappedcall.c +++ b/src/cc65/wrappedcall.c @@ -97,6 +97,6 @@ void GetWrappedCall (void **Ptr, unsigned char *Val) } else { long Temp; IPS_Get (&WrappedCalls, &Temp, Ptr); - *Val = Temp; + *Val = (unsigned char) Temp; } } diff --git a/src/chrcvt65.vcxproj b/src/chrcvt65.vcxproj index 1daf7cae9..d120399d1 100644 --- a/src/chrcvt65.vcxproj +++ b/src/chrcvt65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/cl65.vcxproj b/src/cl65.vcxproj index 64c1126b1..b6ceb161a 100644 --- a/src/cl65.vcxproj +++ b/src/cl65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/cl65/main.c b/src/cl65/main.c index b209cb21d..afd3e97e3 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -380,19 +380,14 @@ static void CmdPrint (CmdDesc* Cmd, FILE* F) static void SetTargetFiles (void) /* Set the target system files */ { - /* Determine the names of the target specific library file */ - if (Target != TGT_NONE) { + /* Get a pointer to the system name and its length */ + const char* TargetName = GetTargetName (Target); + unsigned TargetNameLen = strlen (TargetName); - /* Get a pointer to the system name and its length */ - const char* TargetName = GetTargetName (Target); - unsigned TargetNameLen = strlen (TargetName); - - /* Set the library file */ - TargetLib = xmalloc (TargetNameLen + 4 + 1); - memcpy (TargetLib, TargetName, TargetNameLen); - strcpy (TargetLib + TargetNameLen, ".lib"); - - } + /* Set the library file */ + TargetLib = xmalloc (TargetNameLen + 4 + 1); + memcpy (TargetLib, TargetName, TargetNameLen); + strcpy (TargetLib + TargetNameLen, ".lib"); } @@ -752,6 +747,7 @@ static void Usage (void) "\n" "Long options:\n" " --add-source\t\t\tInclude source as comment\n" + " --all-cdecl\t\t\tMake functions default to __cdecl__\n" " --asm-args options\t\tPass options to the assembler\n" " --asm-define sym[=v]\t\tDefine an assembler symbol\n" " --asm-include-dir dir\t\tSet an assembler include directory\n" @@ -815,6 +811,14 @@ static void OptAddSource (const char* Opt attribute ((unused)), } +static void OptAllCDecl (const char* Opt attribute ((unused)), + const char* Arg attribute ((unused))) +/* Make functions default to __cdecl__ */ +{ + CmdAddArg (&CC65, "--all-cdecl"); +} + + static void OptAsmArgs (const char* Opt attribute ((unused)), const char* Arg) /* Pass arguments to the assembler */ @@ -1290,6 +1294,7 @@ int main (int argc, char* argv []) /* Program long options */ static const LongOpt OptTab[] = { { "--add-source", 0, OptAddSource }, + { "--all-cdecl", 0, OptAllCDecl }, { "--asm-args", 1, OptAsmArgs }, { "--asm-define", 1, OptAsmDefine }, { "--asm-include-dir", 1, OptAsmIncludeDir }, @@ -1439,35 +1444,24 @@ int main (int argc, char* argv []) /* Print version number */ OptVersion (Arg, 0); break; - + case 'E': /* Forward -E to compiler */ CmdAddArg (&CC65, Arg); DisableAssemblingAndLinking (); break; - + case 'W': - /* avoid && with'\0' in if clauses */ - if (Arg[3] == '\0') { - switch (Arg[2]) { - case 'a': - /* -Wa: Pass options to assembler */ - OptAsmArgs (Arg, GetArg (&I, 3)); - break; - case 'c': - /* -Wc: Pass options to compiler - ** Remember -Wc sub arguments in cc65 arg struct - */ - OptCCArgs (Arg, GetArg (&I, 3)); - break; - case 'l': - /* -Wl: Pass options to linker */ - OptLdArgs (Arg, GetArg (&I, 3)); - break; - default: - UnknownOption (Arg); - break; - } + if (Arg[2] == 'a' && Arg[3] == '\0') { + /* -Wa: Pass options to assembler */ + OptAsmArgs (Arg, GetArg (&I, 3)); + } else if (Arg[2] == 'c' && Arg[3] == '\0') { + /* -Wc: Pass options to compiler */ + /* Remember -Wc sub arguments in cc65 arg struct */ + OptCCArgs (Arg, GetArg (&I, 3)); + } else if (Arg[2] == 'l' && Arg[3] == '\0') { + /* -Wl: Pass options to linker */ + OptLdArgs (Arg, GetArg (&I, 3)); } else { /* Anything else: Suppress warnings (compiler) */ CmdAddArg2 (&CC65, "-W", GetArg (&I, 2)); diff --git a/src/co65.vcxproj b/src/co65.vcxproj index c66c8aac8..89eed36e1 100644 --- a/src/co65.vcxproj +++ b/src/co65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/common.vcxproj b/src/common.vcxproj index 39fea35e5..644d6da85 100644 --- a/src/common.vcxproj +++ b/src/common.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -115,13 +115,13 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> <ConfigurationType>StaticLibrary</ConfigurationType> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/common/inttypes.h b/src/common/inttypes.h index 0d9cb75fc..29ac778ef 100644 --- a/src/common/inttypes.h +++ b/src/common/inttypes.h @@ -38,29 +38,28 @@ -/* If we have stdint.h, include it, otherwise try some quesswork on types. +/* If we have <stdint.h>, include it; otherwise, adapt types from <stddef.h>. ** gcc and msvc don't define __STDC_VERSION__ without special flags, so check -** for them explicitly. Undefined symbols are replaced by zero, so a check for -** defined(__GNUC__) or defined(_MSC_VER) is not necessary. +** for them explicitly. Undefined symbols are replaced by zero; so, checks for +** defined(__GNUC__) and defined(_MSC_VER) aren't necessary. */ #if (__STDC_VERSION__ >= 199901) || (__GNUC__ >= 3) || (_MSC_VER >= 1600) #include <stdint.h> #else -/* Assume long is the largest type available, and assume that pointers can be -** safely converted into this type and back. +/* Assume that ptrdiff_t and size_t are wide enough to hold pointers. +** Assume that they are the widest type. */ -typedef long intptr_t; -typedef unsigned long uintptr_t; -typedef long intmax_t; -typedef unsigned long uintmax_t; - +#include <stddef.h> +typedef ptrdiff_t intptr_t; +typedef size_t uintptr_t; +typedef ptrdiff_t intmax_t; +typedef size_t uintmax_t; #endif /* End of inttypes.h */ - #endif diff --git a/src/common/version.c b/src/common/version.c index bf0a6bf71..1f1e8093e 100644 --- a/src/common/version.c +++ b/src/common/version.c @@ -47,7 +47,7 @@ #define VER_MAJOR 2U -#define VER_MINOR 16U +#define VER_MINOR 17U diff --git a/src/common/xsprintf.c b/src/common/xsprintf.c index d50ad7a68..a7d26d5ef 100644 --- a/src/common/xsprintf.c +++ b/src/common/xsprintf.c @@ -352,14 +352,14 @@ static void StoreOffset (PrintfCtrl* P) /* Store the current output offset (%n format spec) */ { switch (P->LengthMod) { - case lmChar: *va_arg (P->ap, int*) = P->BufFill; - case lmShort: *va_arg (P->ap, int*) = P->BufFill; - case lmInt: *va_arg (P->ap, int*) = P->BufFill; - case lmLong: *va_arg (P->ap, long*) = P->BufFill; - case lmIntMax: *va_arg (P->ap, intmax_t*) = P->BufFill; - case lmSizeT: *va_arg (P->ap, size_t*) = P->BufFill; - case lmPtrDiffT: *va_arg (P->ap, ptrdiff_t*) = P->BufFill; - default: FAIL ("Invalid size modifier for %n format spec in xvsnprintf"); + case lmChar: *va_arg (P->ap, int*) = P->BufFill; break; + case lmShort: *va_arg (P->ap, int*) = P->BufFill; break; + case lmInt: *va_arg (P->ap, int*) = P->BufFill; break; + case lmLong: *va_arg (P->ap, long*) = P->BufFill; break; + case lmIntMax: *va_arg (P->ap, intmax_t*) = P->BufFill; break; + case lmSizeT: *va_arg (P->ap, size_t*) = P->BufFill; break; + case lmPtrDiffT: *va_arg (P->ap, ptrdiff_t*) = P->BufFill; break; + default: FAIL ("Invalid size modifier for %n format spec. in xvsnprintf()"); } } diff --git a/src/da65.vcxproj b/src/da65.vcxproj index 2695edc08..06af7505d 100644 --- a/src/da65.vcxproj +++ b/src/da65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/da65/main.c b/src/da65/main.c index 0b0bf19e7..1454d01fb 100644 --- a/src/da65/main.c +++ b/src/da65/main.c @@ -350,6 +350,7 @@ static void OneOpcode (unsigned RemainingBytes) /* Disassemble one opcode */ { unsigned I; + unsigned OldPC = PC; /* Get the opcode from the current address */ unsigned char OPC = GetCodeByte (PC); @@ -476,7 +477,7 @@ static void OneOpcode (unsigned RemainingBytes) /* Change back to the default CODE segment if ** a named segment stops at the current address. */ - for (I = D->Size; I >= 1; --I) { + for (I = PC - OldPC; I > 0; --I) { if (IsSegmentEnd (PC - I)) { EndSegment (); break; diff --git a/src/da65/opc65c02.c b/src/da65/opc65c02.c index 1351f5eee..8133bccae 100644 --- a/src/da65/opc65c02.c +++ b/src/da65/opc65c02.c @@ -157,7 +157,7 @@ const OpcDesc OpcTable_65C02[256] = { { "", 1, flIllegal, OH_Illegal, }, /* $6b */ { "jmp", 3, flLabel, OH_JmpAbsoluteIndirect }, /* $6c */ { "adc", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $6d */ - { "ror", 3, flUseLabel, OH_Absolute }, /* $6e */ + { "ror", 3, flUseLabel|flAbsOverride, OH_Absolute }, /* $6e */ { "bbr6", 3, flUseLabel, OH_BitBranch }, /* $6f */ { "bvs", 2, flLabel, OH_Relative }, /* $70 */ { "adc", 2, flUseLabel, OH_DirectIndirectY }, /* $71 */ diff --git a/src/grc65.vcxproj b/src/grc65.vcxproj index 211ad7cce..afac0cce1 100644 --- a/src/grc65.vcxproj +++ b/src/grc65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/ld65.vcxproj b/src/ld65.vcxproj index acb9b4240..cc5598aad 100644 --- a/src/ld65.vcxproj +++ b/src/ld65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/od65.vcxproj b/src/od65.vcxproj index c788ac961..2ace26001 100644 --- a/src/od65.vcxproj +++ b/src/od65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/sim65.vcxproj b/src/sim65.vcxproj index f87b4db6b..9ba0980ba 100644 --- a/src/sim65.vcxproj +++ b/src/sim65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/src/sim65/6502.c b/src/sim65/6502.c index 1febef657..0d0adbf8b 100644 --- a/src/sim65/6502.c +++ b/src/sim65/6502.c @@ -1266,6 +1266,8 @@ static void OPC_6502_6C (void) Cycles = 6; Regs.PC = MemReadWord(Lo); } + + ParaVirtHooks (&Regs); } @@ -1276,6 +1278,8 @@ static void OPC_65C02_6C (void) /* 6502 bug fixed here */ Cycles = 5; Regs.PC = MemReadWord (MemReadWord (Regs.PC+1)); + + ParaVirtHooks (&Regs); } @@ -1430,6 +1434,8 @@ static void OPC_65SC02_7C (void) PC = Regs.PC; Adr = MemReadWord (PC+1); Regs.PC = MemReadWord(Adr+Regs.XR); + + ParaVirtHooks (&Regs); } diff --git a/src/sp65.vcxproj b/src/sp65.vcxproj index 8db98346c..6e7d992d4 100644 --- a/src/sp65.vcxproj +++ b/src/sp65.vcxproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> @@ -18,12 +18,12 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>true</WholeProgramOptimization> - <PlatformToolset>v120</PlatformToolset> + <PlatformToolset>v140</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> diff --git a/test/val/anon-struct1.c b/test/val/anon-struct1.c new file mode 100644 index 000000000..9a737adca --- /dev/null +++ b/test/val/anon-struct1.c @@ -0,0 +1,111 @@ +/* + !!DESCRIPTION!! Make sure that structs/unions know the sizes of anonymous struct/union members + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Greg King +*/ + +/* + see https://github.com/cc65/cc65/issues/641 +*/ + +#include <stdio.h> + +static unsigned char fails = 0; + +typedef struct { + short s1; + struct { + int i1; + long l1; + char c1; + }; + char c2; +} s1_t; + +typedef struct { + short s1; + union { + int i1; + long l1; + char c1; + }; + char c2; +} s2_t; + +typedef union { + short s1; + struct { + int i1; + long l1; + char c1; + }; + char c2; +} u1_t; + +typedef union { + short s1; + union { + int i1; + long l1; + char c1; + }; + char c2; +} u2_t; + +static s1_t s1; +static s2_t s2; +static u1_t u1; +static u2_t u2; + +/* We use "variables" in the comparisons, so that we can avoid "constant +** comparison" and "Unreachable code" warnings (the second one currently +** can't be suppressed). +*/ + +static size_t const four = 4; +static size_t const seven = 7; +static size_t const ten = 10; + +int main(void) +{ + /* Check the types' sizes. */ + + if (sizeof (s1_t) != ten) { + printf("s1_t size is %u; it should be 10.\n", sizeof (s1_t)); + ++fails; + } + if (sizeof (s2_t) != seven) { + printf("s2_t size is %u; it should be 7.\n", sizeof (s2_t)); + ++fails; + } + if (sizeof (u1_t) != seven) { + printf("u1_t size is %u; it should be 7.\n", sizeof (u1_t)); + ++fails; + } + if (sizeof (u2_t) != four) { + printf("u2_t size is %u; it should be 4.\n", sizeof (u2_t)); + ++fails; + } + + /* Check the variables' sizes. */ + + if (sizeof s1 != ten) { + printf("s1 size is %u; it should be 10.\n", sizeof s1); + ++fails; + } + if (sizeof s2 != seven) { + printf("s2 size is %u; it should be 7.\n", sizeof s2); + ++fails; + } + if (sizeof u1 != seven) { + printf("u1 size is %u; it should be 7.\n", sizeof u1); + ++fails; + } + if (sizeof u2 != four) { + printf("u2 size is %u; it should be 4.\n", sizeof u2); + ++fails; + } + + return fails; +} diff --git a/test/val/anon-struct2.c b/test/val/anon-struct2.c new file mode 100644 index 000000000..bdaddc823 --- /dev/null +++ b/test/val/anon-struct2.c @@ -0,0 +1,152 @@ +/* + !!DESCRIPTION!! Make sure that the fields of anonymous structs/unions can be reached properly. + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Greg King +*/ + +#include <stddef.h> +#include <stdio.h> + +static unsigned char fails = 0; + +typedef struct { + short s1; + struct { + char c1; + int i1; + long l1; + }; + char c2; +} s1_t; + +typedef struct { + char c2; + union { + int i1; + char c1; + long l1; + }; + short s1; +} s2_t; + +typedef union { + short s1; + struct { + int i1; + long l1; + char c1; + }; + char c2; +} u1_t; + +typedef union { + short s1; + union { + long l1; + char c1; + int i1; + }; + char c2; +} u2_t; + +typedef struct { + union { + short s1; + struct { + int i1; + long l1; + char c1; + }; + char c2; + }; + short s2; +} s3_t; + +static s1_t s1; +static s2_t s2; +static u1_t u1; +static u2_t u2; + +static long l2; +static int i2; + +/* We use "variables" in the comparisons, so that we can avoid "constant +** comparison" and "Unreachable code" warnings (the second one currently +** can't be suppressed). +*/ + +static size_t const zero = 0; +static size_t const one = 1; +static size_t const three = 3; +static size_t const five = 5; +static size_t const six = 6; +static size_t const seven = 7; +static size_t const nine = 9; + +int main(void) +{ + /* Can cc65 see the names of members of anonymous structs/unions? */ + + l2 = s1.l1; + l2 = s2.l1; + l2 = u1.l1; + l2 = u2.l1; + + i2 = s1.c1; + i2 = s1.c2; + i2 = s2.c1; + i2 = s2.c2; + i2 = u1.c1; + i2 = u1.c2; + i2 = u2.c1; + i2 = u2.c2; + + /* Does cc65 use the correct offsets of + ** the members of anonymous structs/unions? + */ + + if (offsetof(s1_t, i1) != three) { + printf("The offset of s1.i1 is %u; it should be 3.\n", offsetof(s1_t, i1)); + ++fails; + } + if (offsetof(s2_t, l1) != one) { + printf("The offset of s2.l1 is %u; it should be 1.\n", offsetof(s2_t, l1)); + ++fails; + } + if (offsetof(u1_t, c1) != six) { + printf("The offset of u1.c1 is %u; it should be 6.\n", offsetof(u1_t, c1)); + ++fails; + } + if (offsetof(u2_t, i1) != zero) { + printf("The offset of u2.i1 is %u; it should be 0.\n", offsetof(u2_t, i1)); + ++fails; + } + + /* Does cc65 use the correct offset of a member + ** that's later than an anonymous struct/union? + */ + + if (offsetof(s1_t, c2) != nine) { + printf("The offset of s1.c2 is %u; it should be 9.\n", offsetof(s1_t, c2)); + ++fails; + } + if (offsetof(s2_t, s1) != five) { + printf("The offset of s2.s1 is %u; it should be 5.\n", offsetof(s2_t, s1)); + ++fails; + } + if (offsetof(u1_t, c2) != zero) { + printf("The offset of u1.c2 is %u; it should be 0.\n", offsetof(u1_t, c2)); + ++fails; + } + if (offsetof(u2_t, c2) != zero) { + printf("The offset of u2.c2 is %u; it should be 0.\n", offsetof(u2_t, c2)); + ++fails; + } + if (offsetof(s3_t, s2) != seven) { + printf("The offset of s3.s2 is %u; it should be 7.\n", offsetof(s3_t, s2)); + ++fails; + } + + return fails; +} diff --git a/test/val/assign-use1.c b/test/val/assign-use1.c new file mode 100644 index 000000000..744023530 --- /dev/null +++ b/test/val/assign-use1.c @@ -0,0 +1,36 @@ +/* + !!DESCRIPTION!! Assign an int; then, do an operation that depends directly on that assignment. + !!ORIGIN!! cc65 regression tests + !!LICENCE!! Public Domain + !!AUTHOR!! Greg King +*/ + +#include <stdio.h> + +static unsigned char failures = 0; + +static unsigned int result; +static const unsigned int buffer = 0xABCD; + +int main(void) +{ + result = buffer; + + /* Shift doesn't use high byte (X register); previous assignment should be optimized. */ + result <<= 8; + if (result != 0xCD00) { + ++failures; + printf("assign-use1: left shift is $%X, not $CD00.\n", result); + } + + result = buffer; + + /* Shift does use high byte; previous assignment shouldn't be optimized by OptStore5(). */ + result >>= 8; + if (result != 0x00AB) { + ++failures; + printf("assign-use1: right shift is $%X, not $00AB.\n", result); + } + + return failures; +} diff --git a/testcode/lib/accelerator/Makefile b/testcode/lib/accelerator/Makefile new file mode 100644 index 000000000..6b90a9556 --- /dev/null +++ b/testcode/lib/accelerator/Makefile @@ -0,0 +1,29 @@ +CL ?= cl65 + +all: c64-scpu-test.prg c128-scpu-test.prg c64dtv-test.prg \ + c64-c128-test.prg c128-test.prg chameleon-test.prg \ + c65-test.prg turbomaster-test.prg + +c64-scpu-test.prg: c64-c128-scpu-test.c + $(CL) -t c64 c64-c128-scpu-test.c -o c64-scpu-test.prg + +c128-scpu-test.prg: c64-c128-scpu-test.c + $(CL) -t c128 c64-c128-scpu-test.c -o c128-scpu-test.prg + +c64dtv-test.prg: c64dtv-test.c + $(CL) -t c64 c64dtv-test.c -o c64dtv-test.prg + +c64-c128-test.prg: c64-c128-test.c + $(CL) -t c64 c64-c128-test.c -o c64-c128-test.prg + +c128-test.prg: c64-c128-test.c + $(CL) -t c128 c64-c128-test.c -o c128-test.prg + +chameleon-test.prg: chameleon-test.c + $(CL) -t c64 chameleon-test.c -o chameleon-test.prg + +c65-test.prg: c65-test.c + $(CL) -t c64 c65-test.c -o c65-test.prg + +turbomaster-test.prg: turbomaster-test.c + $(CL) -t c64 turbomaster-test.c -o turbomaster-test.prg diff --git a/testcode/lib/accelerator/c64-c128-scpu-test.c b/testcode/lib/accelerator/c64-c128-scpu-test.c new file mode 100644 index 000000000..975244df5 --- /dev/null +++ b/testcode/lib/accelerator/c64-c128-scpu-test.c @@ -0,0 +1,8 @@ +/* C64/C128 SuperCPU accelerator test code. */ + +#define ACC_DETECT detect_scpu +#define ACC_GET_SPEED get_scpu_speed +#define ACC_SET_SPEED set_scpu_speed +#define ACC_NAME "SuperCPU" + +#include "turbo-test.c" diff --git a/testcode/lib/accelerator/c64-c128-test.c b/testcode/lib/accelerator/c64-c128-test.c new file mode 100644 index 000000000..ba212e03d --- /dev/null +++ b/testcode/lib/accelerator/c64-c128-test.c @@ -0,0 +1,8 @@ +/* C128 in C64 mode accelerator test code. */ + +#define ACC_DETECT detect_c128 +#define ACC_GET_SPEED get_c128_speed +#define ACC_SET_SPEED set_c128_speed +#define ACC_NAME "C128 CPU" + +#include "turbo-test.c" diff --git a/testcode/lib/accelerator/c64dtv-test.c b/testcode/lib/accelerator/c64dtv-test.c new file mode 100644 index 000000000..34f0410d9 --- /dev/null +++ b/testcode/lib/accelerator/c64dtv-test.c @@ -0,0 +1,8 @@ +/* C64DTV accelerator test code. */ + +#define ACC_DETECT detect_c64dtv +#define ACC_GET_SPEED get_c64dtv_speed +#define ACC_SET_SPEED set_c64dtv_speed +#define ACC_NAME "C64DTV" + +#include "turbo-test.c" diff --git a/testcode/lib/accelerator/c65-test.c b/testcode/lib/accelerator/c65-test.c new file mode 100644 index 000000000..02e322625 --- /dev/null +++ b/testcode/lib/accelerator/c65-test.c @@ -0,0 +1,8 @@ +/* C65/C64DX in C64 mode accelerator test code. */ + +#define ACC_DETECT detect_c65 +#define ACC_GET_SPEED get_c65_speed +#define ACC_SET_SPEED set_c65_speed +#define ACC_NAME "C65" + +#include "turbo-test.c" diff --git a/testcode/lib/accelerator/chameleon-test.c b/testcode/lib/accelerator/chameleon-test.c new file mode 100755 index 000000000..ffc1539b5 --- /dev/null +++ b/testcode/lib/accelerator/chameleon-test.c @@ -0,0 +1,8 @@ +/* C64 Chameleon accelerator test code. */ + +#define ACC_DETECT detect_chameleon +#define ACC_GET_SPEED get_chameleon_speed +#define ACC_SET_SPEED set_chameleon_speed +#define ACC_NAME "Chameleon cartridge" + +#include "turbo-test.c" diff --git a/testcode/lib/accelerator/turbo-test.c b/testcode/lib/accelerator/turbo-test.c new file mode 100644 index 000000000..8c854c00c --- /dev/null +++ b/testcode/lib/accelerator/turbo-test.c @@ -0,0 +1,57 @@ +/* Accelerator test code. */ + +#ifndef ACC_DETECT +#error This file cannot be used directly (yet) +#endif + +#include <time.h> +#include <accelerator.h> +#include <stdio.h> +#include <conio.h> +#include <stdlib.h> + +static void print_time_taken(void) +{ + clock_t curtime = clock(); + clock_t newtime; + unsigned long i; + char buffer[10]; + + printf("Doing a speed test, please wait\n"); + for (i = 0; i < 0x1000; i++) { } + newtime = clock() - curtime; + ultoa(newtime, buffer, 10); + printf("Time taken : %s\n", buffer); +} + +static void print_current_speed(void) +{ + unsigned char status; + + status = ACC_GET_SPEED(); + printf("Current "ACC_NAME" speed : %d\n", status + 1); +} + +void main(void) +{ + unsigned char status; + unsigned char speed = 0; + + status = ACC_DETECT(); + clrscr(); + if (status == 0) { + printf("No "ACC_NAME" detected\n"); + } else { + status = ACC_GET_SPEED(); + print_current_speed(); + + /* cycle through all the speeds */ + for (speed = SPEED_1X; speed <= SPEED_20X; ++speed) { + printf("Setting "ACC_NAME" speed to %d\n", speed + 1); + ACC_SET_SPEED(speed); + print_current_speed(); + print_time_taken(); + } + ACC_SET_SPEED(status); + } +} diff --git a/testcode/lib/accelerator/turbomaster-test.c b/testcode/lib/accelerator/turbomaster-test.c new file mode 100755 index 000000000..207465efa --- /dev/null +++ b/testcode/lib/accelerator/turbomaster-test.c @@ -0,0 +1,8 @@ +/* C64 Turbo Master accelerator test code. */ + +#define ACC_DETECT detect_turbomaster +#define ACC_GET_SPEED get_turbomaster_speed +#define ACC_SET_SPEED set_turbomaster_speed +#define ACC_NAME "Turbo Master cartridge" + +#include "turbo-test.c" diff --git a/testcode/lib/apple2/Makefile b/testcode/lib/apple2/Makefile new file mode 100644 index 000000000..9d551aa62 --- /dev/null +++ b/testcode/lib/apple2/Makefile @@ -0,0 +1,37 @@ +# For this one see https://applecommander.github.io/ +AC ?= ac.jar + +CL ?= cl65 + +all: hgr.dsk dhgr.dsk + +hgr.dsk: hgrshow hgrtest + cp prodos.dsk $@ + java -jar $(AC) -as $@ hgrshow <hgrshow + java -jar $(AC) -as $@ hgrtest <hgrtest + java -jar $(AC) -p $@ astronaut.hgr bin 0x2000 <astronaut.hgr + java -jar $(AC) -p $@ chips.hgr bin 0x2000 <chips.hgr + java -jar $(AC) -p $@ macrometer.hgr bin 0x2000 <macrometer.hgr + java -jar $(AC) -p $@ mariner.hgr bin 0x2000 <mariner.hgr + java -jar $(AC) -p $@ rose.hgr bin 0x2000 <rose.hgr + java -jar $(AC) -p $@ werner.hgr bin 0x2000 <werner.hgr + java -jar $(AC) -p $@ winston.hgr bin 0x2000 <winston.hgr + +hgrshow: hgrshow.c + $(CL) -Oirs -t apple2 --start-addr 0x4000 -m hgrshow.map $^ + +hgrtest: hgrtest.c werner.s + $(CL) -Oirs -t apple2 -C apple2-hgr.cfg -m hgrtest.map $^ + +dhgr.dsk: dhgrshow + cp prodos.dsk $@ + java -jar $(AC) -as $@ dhgrshow <dhgrshow + java -jar $(AC) -p $@ catface.dhgr bin 0x2000 <catface.dhgr + java -jar $(AC) -p $@ gatsby.dhgr bin 0x2000 <gatsby.dhgr + java -jar $(AC) -p $@ girl.dhgr bin 0x2000 <girl.dhgr + java -jar $(AC) -p $@ monarch.dhgr bin 0x2000 <monarch.dhgr + java -jar $(AC) -p $@ superman.dhgr bin 0x2000 <superman.dhgr + java -jar $(AC) -p $@ venice.dhgr bin 0x2000 <venice.dhgr + +dhgrshow: dhgrshow.c + $(CL) -Oirs -t apple2enh --start-addr 0x4000 -m dhgrshow.map $^ diff --git a/testcode/lib/apple2/astronaut.hgr b/testcode/lib/apple2/astronaut.hgr new file mode 100644 index 000000000..f19f0099a Binary files /dev/null and b/testcode/lib/apple2/astronaut.hgr differ diff --git a/testcode/lib/apple2/catface.dhgr b/testcode/lib/apple2/catface.dhgr new file mode 100644 index 000000000..1f373d9d0 Binary files /dev/null and b/testcode/lib/apple2/catface.dhgr differ diff --git a/testcode/lib/apple2/chips.hgr b/testcode/lib/apple2/chips.hgr new file mode 100644 index 000000000..c8302db4d Binary files /dev/null and b/testcode/lib/apple2/chips.hgr differ diff --git a/testcode/lib/apple2/dhgrshow.c b/testcode/lib/apple2/dhgrshow.c new file mode 100644 index 000000000..f0b37e461 --- /dev/null +++ b/testcode/lib/apple2/dhgrshow.c @@ -0,0 +1,45 @@ +// cl65 -t apple2enh --start-addr 0x4000 dhgrshow.c + +#include <tgi.h> +#include <conio.h> +#include <fcntl.h> +#include <string.h> +#include <unistd.h> +#include <dirent.h> +#include <peekpoke.h> + +void main (void) +{ + unsigned old; + DIR *dir; + struct dirent *ent; + + old = videomode (VIDEOMODE_80x24); + tgi_install (a2e_hi_tgi); + tgi_init (); + POKE (0xC05E, 0); + + dir = opendir ("."); + while (ent = readdir (dir)) { + char *ext; + int hgr; + + ext = strrchr (ent->d_name, '.'); + if (!ext || strcasecmp (ext, ".dhgr")) + continue; + + hgr = open (ent->d_name, O_RDONLY); + POKE (0xC055, 0); + read (hgr, (void*)0x2000, 0x2000); + POKE (0xC054, 0); + read (hgr, (void*)0x2000, 0x2000); + close (hgr); + + if (cgetc () == '\r') + break; + } + closedir (dir); + + tgi_uninstall (); + videomode (old); +} diff --git a/testcode/lib/apple2/gatsby.dhgr b/testcode/lib/apple2/gatsby.dhgr new file mode 100644 index 000000000..dc3750e66 Binary files /dev/null and b/testcode/lib/apple2/gatsby.dhgr differ diff --git a/testcode/lib/apple2/girl.dhgr b/testcode/lib/apple2/girl.dhgr new file mode 100644 index 000000000..af332edbe Binary files /dev/null and b/testcode/lib/apple2/girl.dhgr differ diff --git a/testcode/lib/apple2/hgrshow.c b/testcode/lib/apple2/hgrshow.c new file mode 100644 index 000000000..518395715 --- /dev/null +++ b/testcode/lib/apple2/hgrshow.c @@ -0,0 +1,37 @@ +// cl65 -t apple2 --start-addr 0x4000 hgrshow.c + +#include <tgi.h> +#include <conio.h> +#include <fcntl.h> +#include <string.h> +#include <unistd.h> +#include <dirent.h> + +void main (void) +{ + DIR *dir; + struct dirent *ent; + + tgi_install (a2_hi_tgi); + tgi_init (); + + dir = opendir ("."); + while (ent = readdir (dir)) { + char *ext; + int hgr; + + ext = strrchr (ent->d_name, '.'); + if (!ext || strcasecmp (ext, ".hgr")) + continue; + + hgr = open (ent->d_name, O_RDONLY); + read (hgr, (void*)0x2000, 0x2000); + close (hgr); + + if (cgetc () == '\r') + break; + } + closedir (dir); + + tgi_uninstall (); +} diff --git a/testcode/lib/apple2/hgrtest.c b/testcode/lib/apple2/hgrtest.c new file mode 100644 index 000000000..7323cbb73 --- /dev/null +++ b/testcode/lib/apple2/hgrtest.c @@ -0,0 +1,26 @@ +// cl65 -t apple2 -C apple2-hgr.cfg hgrtest.c werner.s + +#include <tgi.h> +#include <conio.h> + +#pragma code-name (push, "LOWCODE") + +void say (const char* text) +{ + tgi_setcolor (TGI_COLOR_BLACK); + tgi_outtextxy (41, 33, text); +} + +#pragma code-name (pop) + +void main (void) +{ + tgi_install (a2_hi_tgi); + tgi_init (); + cgetc (); + + say ("Hi Dude !"); + cgetc (); + + tgi_uninstall (); +} diff --git a/testcode/lib/apple2/macrometer.hgr b/testcode/lib/apple2/macrometer.hgr new file mode 100644 index 000000000..925df6e41 Binary files /dev/null and b/testcode/lib/apple2/macrometer.hgr differ diff --git a/testcode/lib/apple2/mariner.hgr b/testcode/lib/apple2/mariner.hgr new file mode 100644 index 000000000..2024a7596 Binary files /dev/null and b/testcode/lib/apple2/mariner.hgr differ diff --git a/testcode/lib/apple2/monarch.dhgr b/testcode/lib/apple2/monarch.dhgr new file mode 100644 index 000000000..8812c4b2d Binary files /dev/null and b/testcode/lib/apple2/monarch.dhgr differ diff --git a/testcode/lib/apple2/rose.hgr b/testcode/lib/apple2/rose.hgr new file mode 100644 index 000000000..d18fd83f0 Binary files /dev/null and b/testcode/lib/apple2/rose.hgr differ diff --git a/testcode/lib/apple2/superman.dhgr b/testcode/lib/apple2/superman.dhgr new file mode 100644 index 000000000..4886227c2 Binary files /dev/null and b/testcode/lib/apple2/superman.dhgr differ diff --git a/testcode/lib/apple2/venice.dhgr b/testcode/lib/apple2/venice.dhgr new file mode 100644 index 000000000..9d3cb4c85 Binary files /dev/null and b/testcode/lib/apple2/venice.dhgr differ diff --git a/testcode/lib/apple2/werner.hgr b/testcode/lib/apple2/werner.hgr new file mode 100644 index 000000000..2405e2409 Binary files /dev/null and b/testcode/lib/apple2/werner.hgr differ diff --git a/testcode/lib/apple2/werner.s b/testcode/lib/apple2/werner.s new file mode 100644 index 000000000..f9200f694 --- /dev/null +++ b/testcode/lib/apple2/werner.s @@ -0,0 +1,2 @@ +.segment "HGR" +.incbin "werner.hgr" diff --git a/testcode/lib/apple2/winston.hgr b/testcode/lib/apple2/winston.hgr new file mode 100644 index 000000000..074ff178d Binary files /dev/null and b/testcode/lib/apple2/winston.hgr differ diff --git a/testcode/lib/cpeek-test.c b/testcode/lib/cpeek-test.c new file mode 100644 index 000000000..1777bce4a --- /dev/null +++ b/testcode/lib/cpeek-test.c @@ -0,0 +1,310 @@ +/* Test that the cpeek...() functions are the inverses of cputc(), +** revers(), and textcolor() for the full range of character codes. +** +** 2017-07-15, Greg King +** 2017-12-12, Groepaz +*/ + +#include <conio.h> +#include <cc65.h> + +/* Standard location of the screen */ + +#if defined(__C128__) || defined(__C64__) +/* only 40-column screen */ +# define SCREEN_RAM ((unsigned char*)0x0400) +#elif defined(__C16__) /* Plus4 also */ +# define SCREEN_RAM ((unsigned char*)0x0C00) +#elif defined(__CBM510__) +# define SCREEN_RAM ((unsigned char*)0xF000) +# define COLOR_RAM ((unsigned char*)0xd400) +#elif defined(__CBM610__) +# define SCREEN_RAM ((unsigned char*)0xD000) +#elif defined(__PET__) +# define SCREEN_RAM ((unsigned char*)0x8000) +#elif defined(__VIC20__) +# define SCREEN_RAM ((unsigned char*)0x1000) +#else +# error This program cannot test that target. +# define SCREEN_RAM ((unsigned char*)0) +#endif + +static unsigned char width; + + +/* Move the cursor backward one char with +** the recognition of a row change. +*/ +static void chBack (void) +{ + unsigned char y = wherey (); + unsigned char x = wherex (); + + if (x == 0) { + x = width; + --y; + } + --x; + + gotoxy (x, y); +} + + +/* Move the cursor forward one char with +** the recognition of a row change. +*/ +static void chForth (void) +{ + unsigned char y = wherey (); + unsigned char x = wherex (); + + if (++x >= width) { + x = 0; + ++y; + } + + gotoxy (x, y); +} + + +/* A hack to get an unmodified byte from the +** screen memory at the current cursor position. +*/ +static unsigned char peekChWithoutTranslation (void) +{ +#if defined(__CBM610__) + return peekbsys ((unsigned)&SCREEN_RAM[wherey () * width + wherex ()]); +#else + return SCREEN_RAM[wherey () * width + wherex ()]; +#endif +} + +/* as above, but for color ram */ +static unsigned char peekColWithoutTranslation (void) +{ +#if defined(__CBM610__) || defined (__PET__) + return COLOR_WHITE; +#elif defined(__C128__) || defined(__C64__) || defined(__VIC20__) || defined(__CBM510__) + return COLOR_RAM[wherey () * width + wherex ()] & 0x0f; +#else + return COLOR_RAM[wherey () * width + wherex ()]; +#endif +} + + +/* A test which outputs the given char, reads it back from +** screen memory, outputs the returned char at the next position, +** then compares the two screen memory bytes for identity. +** +** Note: cpeekc() must be tested indirectly because some platforms "fold" their +** character code-set into a smaller screen code-set. Therefore, cpeekc() might +** return an equivalent, but not equal, character to the one that was cputc(). +*/ +static unsigned char testCPeekC (char ch) +{ + unsigned char ch2_a, ch2_b, ch2_c; + + /* Test the given char-code, but not the + ** special characters NEWLINE and RETURN + ** (they don't put anything on the screen). + */ + if (('\n' == ch) || ('\r' == ch) + ) { + return 1; + } + + /* toggle revers mode every few chars so cpeekc gets tested for both */ + revers ((ch >> 3) & 1); + + /* output additional space every now and then, that way not only even or only + odd half of the character cell will be tested */ +#if defined(__C64__) + if ((width == 80) && ((ch % 17) == 0)) { + cputc(' '); + } +#endif + + /* Output the char to the screen. */ + cputc (ch); + + /* Move the cursor pos. to the previous output. */ + chBack (); + + /* Get back the written char without any translation. */ + ch2_b = peekChWithoutTranslation (); + + /* Get back the written char, + ** including the translation, screen-code -> text. + */ + ch2_a = cpeekc (); + + /* Move the cursor to the following writing position. */ + chForth (); + + /* Output again the char which was read back by cpeekc(). */ + cputc (ch2_a); + + /* Move the cursor pos. to the second output. */ + chBack (); + + /* Get back the second written char without any translation; + ** and, compare it to the first untranslated char. + */ + ch2_c = peekChWithoutTranslation (); + if ((ch2_c != ch2_b) +#if defined(__C128__) || defined(__C64__) + /* VDC memory is not accessible, soft80 has no "videoram" */ + && (width == 40) +#endif + ){ + /* The test was NOT succesful. + ** Output a diagnostic; and, return FAILURE. + */ + revers(0); + cprintf ("\r\nError on char: %#x was %#x instead.", ch, ch2_a); + cprintf ("\r\nRaw screen codes: %#x, %#x.", ch2_b, ch2_c); + cprintf ("\r\nscreen width: %#d", width); + return 0; + } + + /* The test was succesful. + ** Move the cursor to the following writing position. + */ + chForth (); + return 1; +} + +static unsigned char testCPeekCol (char ch) +{ + unsigned char ch2_a, ch2_b, ch2_c; + + /* Output the char to the screen. */ + textcolor (ch); + cputc ('*'); + + /* Move the cursor pos. to the previous output. */ + chBack (); + + /* Get back the written char without any translation. */ + ch2_b = peekColWithoutTranslation (); + + /* Get back the written char, + ** including the translation, screen-code -> text. + */ + ch2_a = cpeekcolor (); + + /* Move the cursor to the following writing position. */ + chForth (); + + /* Output again the char which was read back by cpeekc(). */ + textcolor (ch2_a); + cputc ('x'); + + /* Move the cursor pos. to the second output. */ + chBack (); + + /* Get back the second written char without any translation; + ** and, compare it to the first untranslated char. + */ + ch2_c = peekColWithoutTranslation (); + if ((ch2_c != ch2_b) +#if defined(__C128__) + /* VDC memory is not accessible */ + && (width == 40) +#endif + ){ + /* The test was NOT succesful. + ** Output a diagnostic; and, return FAILURE. + */ + revers(0); + cprintf ("\r\nError on color: %#x was %#x instead.", ch, ch2_a); + cprintf ("\r\nRaw color codes: %#x, %#x.", ch2_b, ch2_c); + return 0; + } + + /* The test was succesful. + ** Move the cursor to the following writing position. + */ + chForth (); + return 1; +} + +/* The main code initiates the screen for the tests, and sets the reverse flag. +** Then, it calls testCPeekC() for every char within 0..255. +** Then, it calls testCPeekCol() for each color +** Returns zero for success, one for failure. +*/ +int main (void) +{ + unsigned char i, c1, c2; + char s[10]; + int ret = 0; + + clrscr (); + revers (0); + textcolor(1); + bgcolor(0); + screensize (&width, &i); + +#if defined(__VIC20__) + /* The VIC-20's screen is too small to hold the full test. */ + i = 2; +#else + i = 0; +#endif + do { + if (!testCPeekC (i)) { + ret = 1; + goto exiterror; + } + } while (++i != 0); /* will wrap around when finished */ + +#if defined(__VIC20__) + cgetc(); +#endif + + /* test colors */ +#if defined(__VIC20__) + clrscr (); +#endif + revers (0); + textcolor(1); + +#if defined (__CBM610__) || defined (__PET__) + cprintf("\n\rno COLOR_RAM\n\r"); +#elif defined (__C128__) || defined (__C64__) + if (width == 40) { + cprintf("\n\rCOLOR_RAM at $%04x\n\r", COLOR_RAM); + } else { + cprintf("\n\rno COLOR_RAM\n\r"); + } +#else + cprintf("\n\rCOLOR_RAM at $%04x\n\r", COLOR_RAM); +#endif + + do { + if (!testCPeekCol (i)) { + ret = 1; + goto exiterror; + } + } while (++i != 16); /* max 16 colors */ + + /* test revers */ + textcolor(1); cputc('\n'); cputc('\r'); + revers(0); cputc('x'); chBack (); c1 = cpeekrevers(); chForth(); + revers(1); cputc('X'); chBack (); c2 = cpeekrevers(); chForth(); + cputc('\n'); cputc('\r'); + revers(c1); cputc('o'); + revers(c2); cputc('O'); + + /* test cpeeks() */ + revers(0); + cprintf("\n\rtest1234"); gotox(0); cpeeks(s, 8); cputs("\n"); + cputs(s); + +exiterror: + if (doesclrscrafterexit()) { + cgetc(); + } + return ret; +} diff --git a/testcode/lib/joy-test.c b/testcode/lib/joy-test.c index fdd83bb4e..3d584bf9d 100644 --- a/testcode/lib/joy-test.c +++ b/testcode/lib/joy-test.c @@ -5,7 +5,6 @@ #include <conio.h> #include <joystick.h> - #ifdef JOYSTICK_DRIVER /* A statically linked driver was named on the compiler's command line. @@ -13,6 +12,22 @@ */ # undef DYN_DRV # define DYN_DRV 0 + +/* +** link existing drivers like this: +** +** cl65 -DJOYSTICK_DRIVER=c64_hitjoy_joy -o joy-test.prg joy-test.c +** +** for testing a new driver you will have to uncomment the define below, and +** link your driver like this: +** +** co65 ../../target/c64/drv/joy/c64-hitjoy.joy -o hitjoy.s --code-label _hitjoy +** cl65 -DJOYSTICK_DRIVER=hitjoy -o joy-test.prg joy-test.c hitjoy.s +** +*/ + +/* extern char JOYSTICK_DRIVER; */ + #else /* Use a dynamically loaded driver, by default. */ @@ -27,13 +42,17 @@ int main (void) unsigned char j; unsigned char count; unsigned char i; + unsigned char Res; + unsigned char ch, kb; + + clrscr (); #if DYN_DRV - unsigned char Res = joy_load_driver (joy_stddrv); + Res = joy_load_driver (joy_stddrv); #elif defined(JOYSTICK_DRIVER) - unsigned char Res = joy_install (&JOYSTICK_DRIVER); + Res = joy_install (&JOYSTICK_DRIVER); #else - unsigned char Res = joy_install (&joy_static_stddrv); + Res = joy_install (&joy_static_stddrv); #endif if (Res != JOY_ERR_OK) { @@ -44,7 +63,6 @@ int main (void) exit (EXIT_FAILURE); } - clrscr (); count = joy_count (); #if defined(__ATARI5200__) || defined(__CREATIVISION__) cprintf ("JOYSTICKS: %d", count); @@ -56,23 +74,31 @@ int main (void) gotoxy (0, i+1); j = joy_read (i); #if defined(__ATARI5200__) || defined(__CREATIVISION__) - cprintf ("%1d:%-3s%-3s%-3s%-3s%-3s%-3s", + cprintf ("%1d:%-3s%-3s%-3s%-3s%-3s %02x", i, JOY_UP(j)? " U " : " - ", JOY_DOWN(j)? " D " : " - ", JOY_LEFT(j)? " L " : " - ", JOY_RIGHT(j)? " R " : " - ", - JOY_BTN_1(j)? " 1 " : " - "); + JOY_BTN_1(j)? " 1 " : " - ", j); #else - cprintf ("%2d: %-6s%-6s%-6s%-6s%-6s%-6s", + cprintf ("%2d: %-6s%-6s%-6s%-6s%-6s %02x", i, JOY_UP(j)? " up " : " ---- ", JOY_DOWN(j)? " down " : " ---- ", JOY_LEFT(j)? " left " : " ---- ", JOY_RIGHT(j)? "right " : " ---- ", - JOY_BTN_1(j)? "button" : " ---- "); + JOY_BTN_1(j)? "button" : " ---- ", j); #endif } + + /* show pressed key, so we can verify keyboard is working */ + kb = kbhit (); + ch = kb ? cgetc () : ' '; + gotoxy (1, i+2); + revers (kb); + cprintf ("kbd: %c", ch); + revers (0); } return 0; } diff --git a/testcode/lib/pce/Makefile b/testcode/lib/pce/Makefile index 9a4dd7506..a4a495c9a 100644 --- a/testcode/lib/pce/Makefile +++ b/testcode/lib/pce/Makefile @@ -1,12 +1,29 @@ .PHONY: all clean test +# Size of cartridge to generate. +# Possible values: +# 8K = 0x2000 +# 16K = 0x4000 +# 32K = 0x8000 +CARTSIZE := 0x2000 + +ifeq (${CARTSIZE},0x8000) +COUNT := 3 +else +COUNT := 1 +endif + all: conio.pce -conio.pce: conio.c - ../../../bin/cl65 -t pce conio.c --mapfile conio.map -o conio.pce +%.pce: %.bin + dd if=$< bs=8K skip=${COUNT} > $@ + dd if=$< bs=8K count=${COUNT} >> $@ + +%.bin: %.c ../../../lib/pce.lib + ../../../bin/cl65 -t pce $< -Wl -D__CARTSIZE__=${CARTSIZE} -m $*.map -o $@ clean: - $(RM) conio.o conio.pce conio.map + $(RM) conio.o conio.??? test: conio.pce - mednafen -force_module pce conio.pce + mednafen -force_module pce $< diff --git a/testcode/lib/pce/conio.c b/testcode/lib/pce/conio.c index ed3f86240..858f01918 100644 --- a/testcode/lib/pce/conio.c +++ b/testcode/lib/pce/conio.c @@ -45,7 +45,7 @@ void main(void) p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15] ); } - memcpy(p, main, 0); /* test that a zero length doesn't copy 64K */ + memcpy(p, main, i = 0); /* test that a zero length doesn't copy 64K */ gotoxy(0,ysize - 1); for (i = 0; i < xsize; ++i) {