diff --git a/cfg/apple2-hgr.cfg b/cfg/apple2-hgr.cfg new file mode 100644 index 000000000..536491c67 --- /dev/null +++ b/cfg/apple2-hgr.cfg @@ -0,0 +1,48 @@ +# Configuration for programs including a hires screen (with 6KB LOWCODE) + +FEATURES { + STARTADDRESS: default = $0803; +} +SYMBOLS { + __EXEHDR__: type = import; + __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 - 4, size = $0004; + 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; + 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-hgr.cfg b/cfg/apple2enh-hgr.cfg new file mode 100644 index 000000000..536491c67 --- /dev/null +++ b/cfg/apple2enh-hgr.cfg @@ -0,0 +1,48 @@ +# Configuration for programs including a hires screen (with 6KB LOWCODE) + +FEATURES { + STARTADDRESS: default = $0803; +} +SYMBOLS { + __EXEHDR__: type = import; + __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 - 4, size = $0004; + 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; + 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/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/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/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/include/apple2.h b/include/apple2.h index 421b5db6c..31e56a95a 100644 --- a/include/apple2.h +++ b/include/apple2.h @@ -134,6 +134,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/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/extra/iobuf-0800.s b/libsrc/apple2/extra/iobuf-0800.s index 0ad7a751f..7ed832ed3 100644 --- a/libsrc/apple2/extra/iobuf-0800.s +++ b/libsrc/apple2/extra/iobuf-0800.s @@ -7,7 +7,7 @@ .constructor initiobuf .export iobuf_alloc, iobuf_free - .import __STARTUP_RUN__ + .import __MAIN_START__ .import incsp2, popax .include "zeropage.inc" @@ -18,7 +18,7 @@ initiobuf: ; Convert end address highbyte to table index - lda #>__STARTUP_RUN__ + lda #>__MAIN_START__ sec sbc #>$0800 lsr 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 # 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/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/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/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/expr.c b/src/cc65/expr.c index dfd5366bb..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 */ @@ -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/cl65/main.c b/src/cl65/main.c index 565f20b45..5a2103b24 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"); } 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 , include it; otherwise, adapt types from . ** 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 #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 +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/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/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/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 +#include + +#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/werner.pic b/testcode/lib/apple2/werner.pic new file mode 100644 index 000000000..2405e2409 Binary files /dev/null and b/testcode/lib/apple2/werner.pic differ diff --git a/testcode/lib/apple2/werner.s b/testcode/lib/apple2/werner.s new file mode 100644 index 000000000..6456ade13 --- /dev/null +++ b/testcode/lib/apple2/werner.s @@ -0,0 +1,2 @@ +.segment "HGR" +.incbin "werner.pic" diff --git a/testcode/lib/cpeek-test.c b/testcode/lib/cpeek-test.c index 5f3bfc524..1777bce4a 100644 --- a/testcode/lib/cpeek-test.c +++ b/testcode/lib/cpeek-test.c @@ -113,6 +113,17 @@ static unsigned char testCPeekC (char 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); @@ -141,8 +152,8 @@ static unsigned char testCPeekC (char ch) */ ch2_c = peekChWithoutTranslation (); if ((ch2_c != ch2_b) -#if defined(__C128__) - /* VDC memory is not accessable */ +#if defined(__C128__) || defined(__C64__) + /* VDC memory is not accessible, soft80 has no "videoram" */ && (width == 40) #endif ){ @@ -198,7 +209,7 @@ static unsigned char testCPeekCol (char ch) ch2_c = peekColWithoutTranslation (); if ((ch2_c != ch2_b) #if defined(__C128__) - /* VDC memory is not accessable */ + /* VDC memory is not accessible */ && (width == 40) #endif ){ @@ -230,7 +241,7 @@ int main (void) int ret = 0; clrscr (); - revers (1); + revers (0); textcolor(1); bgcolor(0); screensize (&width, &i); @@ -261,7 +272,7 @@ int main (void) #if defined (__CBM610__) || defined (__PET__) cprintf("\n\rno COLOR_RAM\n\r"); -#elif defined (__C128__) +#elif defined (__C128__) || defined (__C64__) if (width == 40) { cprintf("\n\rCOLOR_RAM at $%04x\n\r", COLOR_RAM); } else {