]> git.sur5r.net Git - cc65/commitdiff
Merge branch 'master' of https://github.com/jedeoric/cc65
authorjede <jede@oric.org>
Mon, 23 Oct 2017 21:04:22 +0000 (23:04 +0200)
committerjede <jede@oric.org>
Mon, 23 Oct 2017 21:04:22 +0000 (23:04 +0200)
297 files changed:
.gitattributes [new file with mode: 0644]
.travis.yml
Makefile
asminc/atari5200.inc
asminc/c128.inc
asminc/c64.inc
asminc/creativision.inc
asminc/joy-kernel.inc
asminc/opcodes.inc
asminc/pet.inc
asminc/plus4.inc
asminc/smc.inc
asminc/vic20.inc
cfg/creativision.cfg
cfg/sim6502.cfg
cfg/sim65c02.cfg
doc/Makefile
doc/apple2.sgml
doc/apple2enh.sgml
doc/ar65.sgml
doc/ca65.sgml
doc/cbm510.sgml
doc/cc65.sgml
doc/cl65.sgml
doc/funcref.sgml
doc/ld65.sgml
doc/nes.sgml
doc/pce.sgml
doc/supervision.sgml
doc/telestrat.sgml
doc/vic20.sgml
include/apple2.h
include/apple2_filetype.h [new file with mode: 0644]
include/atari.h
include/atari5200.h
include/atmos.h
include/c128.h
include/c64.h
include/cbm.h
include/cbm264.h
include/cbm510.h
include/conio.h
include/creativision.h
include/ctype.h
include/em/em-kernel.h
include/gamate.h
include/geos.h
include/joystick.h
include/joystick/joy-kernel.h
include/lynx.h
include/lz4.h [new file with mode: 0644]
include/nes.h
include/osic1p.h
include/pce.h
include/pet.h
include/vic20.h
include/zlib.h
libsrc/Makefile
libsrc/apple2/joy/a2.stdjoy.s
libsrc/atari/cgetc.s
libsrc/atari/joy/atrmj8.s
libsrc/atari/joy/atrstd.s
libsrc/atari/setcursor.s [new file with mode: 0644]
libsrc/atari5200/joy/atr5200std.s
libsrc/atmos/gotoxy.s
libsrc/atmos/joy/atmos-pase.s
libsrc/c128/joy/c128-ptvjoy.s
libsrc/c128/joy/c128-stdjoy.s
libsrc/c128/kbrepeat.s [new file with mode: 0644]
libsrc/c128/waitvsync.s [new file with mode: 0644]
libsrc/c64/emd/c64-65816.s
libsrc/c64/joy/c64-hitjoy.s
libsrc/c64/joy/c64-numpad.s
libsrc/c64/joy/c64-ptvjoy.s
libsrc/c64/joy/c64-stdjoy.s
libsrc/c64/kbrepeat.s [new file with mode: 0644]
libsrc/c64/waitvsync.s [new file with mode: 0644]
libsrc/cbm510/joy/cbm510-std.s
libsrc/cbm510/waitvsync.s [new file with mode: 0644]
libsrc/common/lz4.s [new file with mode: 0644]
libsrc/common/memmove.s
libsrc/common/rand.s
libsrc/common/strcat.s
libsrc/common/strchr.s
libsrc/common/strcspn.s
libsrc/common/strftime.c
libsrc/common/strlen.s
libsrc/common/strncat.s
libsrc/common/strrchr.s
libsrc/common/strspn.s
libsrc/conio/cputs.s
libsrc/creativision/clrscr.s
libsrc/creativision/cputc.s
libsrc/creativision/crt0.s
libsrc/creativision/gotoxy.s
libsrc/creativision/joy/creativision-stdjoy.s
libsrc/creativision/mainargs.s [deleted file]
libsrc/dbg/dbg.c
libsrc/gamate/gotoxy.s
libsrc/gamate/joy/gamate-stdjoy.s
libsrc/gamate/waitvblank.s [deleted file]
libsrc/gamate/waitvsync.s [new file with mode: 0644]
libsrc/geos-cbm/joy/geos-stdjoy.s
libsrc/geos-common/dlgbox/messagebox.c
libsrc/joystick/joy-kernel.s
libsrc/lynx/joy/lynx-stdjoy.s
libsrc/nes/joy/nes-stdjoy.s
libsrc/nes/waitvblank.s [deleted file]
libsrc/nes/waitvsync.s [new file with mode: 0644]
libsrc/osic1p/cgetc.s
libsrc/osic1p/doesclrscr.s [new file with mode: 0644]
libsrc/osic1p/osic1p.inc
libsrc/osic1p/osiscreen.inc
libsrc/osic1p/revers.s [new file with mode: 0644]
libsrc/pce/joy/pce-stdjoy.s
libsrc/pce/waitvblank.s [deleted file]
libsrc/pce/waitvsync.s [new file with mode: 0644]
libsrc/pet/joy/pet-ptvjoy.s
libsrc/pet/joy/pet-stdjoy.s
libsrc/pet/kbrepeat.s [new file with mode: 0644]
libsrc/plus4/joy/plus4-stdjoy.s
libsrc/plus4/kbrepeat.s [new file with mode: 0644]
libsrc/plus4/waitvsync.s [new file with mode: 0644]
libsrc/runtime/add.s
libsrc/runtime/along.s
libsrc/runtime/axlong.s
libsrc/runtime/callptr4.s [new file with mode: 0644]
libsrc/runtime/laddeq.s
libsrc/runtime/land.s
libsrc/runtime/leave.s
libsrc/runtime/lmod.s
libsrc/runtime/lmul.s
libsrc/runtime/lor.s
libsrc/runtime/lpop.s
libsrc/runtime/lpush.s
libsrc/runtime/lrsub.s
libsrc/runtime/lsave.s
libsrc/runtime/lsub.s
libsrc/runtime/lsubeq.s
libsrc/runtime/ludiv.s
libsrc/runtime/lumod.s
libsrc/runtime/lxor.s
libsrc/runtime/makebool.s
libsrc/runtime/or.s
libsrc/runtime/rsub.s
libsrc/runtime/staxspi.s
libsrc/runtime/swap.s
libsrc/runtime/xor.s
libsrc/telestrat/gotoxy.s
libsrc/vic20/joy/vic20-ptvjoy.s
libsrc/vic20/joy/vic20-stdjoy.s
libsrc/vic20/kbrepeat.s [new file with mode: 0644]
libsrc/vic20/waitvsync.s [new file with mode: 0644]
samples/Makefile
src/Makefile
src/ar65/list.c
src/ar65/main.c
src/ca65/dbginfo.c
src/ca65/feature.c
src/ca65/main.c
src/ca65/pseudo.c
src/ca65/scanner.c
src/ca65/scanner.h
src/cc65.vcxproj
src/cc65/codegen.c
src/cc65/codeinfo.c
src/cc65/compile.c
src/cc65/coptstop.c
src/cc65/datatype.c
src/cc65/declare.c
src/cc65/expr.c
src/cc65/funcdesc.c
src/cc65/funcdesc.h
src/cc65/global.c
src/cc65/global.h
src/cc65/main.c
src/cc65/pragma.c
src/cc65/standard.c
src/cc65/stdfunc.c
src/cc65/stmt.c
src/cc65/symentry.c
src/cc65/symentry.h
src/cc65/symtab.c
src/cc65/wrappedcall.c [new file with mode: 0644]
src/cc65/wrappedcall.h [new file with mode: 0644]
src/cl65/main.c
src/co65/model.c
src/common.vcxproj
src/common/intptrstack.c [new file with mode: 0644]
src/common/intptrstack.h [new file with mode: 0644]
src/common/version.c
src/da65/labels.c
src/grc65/main.c
src/sim65/6502.c
src/sp65/attr.c
src/sp65/attr.h
src/sp65/main.c
test/Makefile
test/asm/4510-cpudetect.ref [new file with mode: 0644]
test/asm/4510-opcodes.ref [new file with mode: 0644]
test/asm/4510-opcodes.s [new file with mode: 0644]
test/asm/6502-cpudetect.ref [new file with mode: 0644]
test/asm/6502-opcodes.ref [new file with mode: 0644]
test/asm/6502-opcodes.s [new file with mode: 0644]
test/asm/6502x-cpudetect.ref [new file with mode: 0644]
test/asm/6502x-opcodes.ref [new file with mode: 0644]
test/asm/6502x-opcodes.s [new file with mode: 0644]
test/asm/65816-cpudetect.ref [new file with mode: 0644]
test/asm/65c02-cpudetect.ref [new file with mode: 0644]
test/asm/65c02-opcodes.ref [new file with mode: 0644]
test/asm/65c02-opcodes.s [new file with mode: 0644]
test/asm/65sc02-cpudetect.ref [new file with mode: 0644]
test/asm/65sc02-opcodes.ref [new file with mode: 0644]
test/asm/65sc02-opcodes.s [new file with mode: 0644]
test/asm/Makefile [new file with mode: 0644]
test/asm/README [new file with mode: 0644]
test/asm/cpudetect.s [new file with mode: 0644]
test/asm/huc6280-cpudetect.ref [new file with mode: 0644]
test/asm/huc6280-opcodes.ref [new file with mode: 0644]
test/asm/huc6280-opcodes.s [new file with mode: 0644]
test/asm/m740-opcodes.s [new file with mode: 0644]
test/assembler/.gitignore [deleted file]
test/assembler/4510-cpudetect.ref [deleted file]
test/assembler/4510-opcodes.ref [deleted file]
test/assembler/4510-opcodes.s [deleted file]
test/assembler/6502-cpudetect.ref [deleted file]
test/assembler/6502-opcodes.ref [deleted file]
test/assembler/6502-opcodes.s [deleted file]
test/assembler/6502x-cpudetect.ref [deleted file]
test/assembler/6502x-opcodes.ref [deleted file]
test/assembler/6502x-opcodes.s [deleted file]
test/assembler/65816-cpudetect.ref [deleted file]
test/assembler/65c02-cpudetect.ref [deleted file]
test/assembler/65c02-opcodes.ref [deleted file]
test/assembler/65c02-opcodes.s [deleted file]
test/assembler/65sc02-cpudetect.ref [deleted file]
test/assembler/65sc02-opcodes.ref [deleted file]
test/assembler/65sc02-opcodes.s [deleted file]
test/assembler/Makefile [deleted file]
test/assembler/README [deleted file]
test/assembler/cpudetect.s [deleted file]
test/assembler/huc6280-cpudetect.ref [deleted file]
test/assembler/huc6280-opcodes.ref [deleted file]
test/assembler/huc6280-opcodes.s [deleted file]
test/assembler/m740-opcodes.s [deleted file]
test/dasm/4510-disass.s [new file with mode: 0644]
test/dasm/Makefile [new file with mode: 0644]
test/disassembler/4510-disass.s [deleted file]
test/disassembler/Makefile [deleted file]
test/err/Makefile
test/err/bss-name-conflict.c [new file with mode: 0644]
test/err/duplicate-global-static.c [new file with mode: 0644]
test/err/duplicate-global.c [new file with mode: 0644]
test/err/duplicate-static-global.c [new file with mode: 0644]
test/err/duplicate-static.c [new file with mode: 0644]
test/err/void-empty.c [new file with mode: 0644]
test/err/void-size2.c [new file with mode: 0644]
test/misc/Makefile
test/ref/Makefile
test/ref/divmod.c
test/ref/init.c
test/ref/pointer2.c
test/ref/switch2.c
test/ref/varargs.c
test/ref/yacc.c
test/val/Makefile
test/val/atoi-test.c [deleted file]
test/val/bss-name-decl.c [new file with mode: 0644]
test/val/bss-name.c [new file with mode: 0644]
test/val/lib_common_atoi.c [new file with mode: 0644]
test/val/lib_common_memmove.c [new file with mode: 0644]
test/val/lib_common_strcat.c [new file with mode: 0644]
test/val/lib_common_strchr.c [new file with mode: 0644]
test/val/lib_common_strcspn.c [new file with mode: 0644]
test/val/lib_common_strncat.c [new file with mode: 0644]
test/val/lib_common_strol.c [new file with mode: 0644]
test/val/lib_common_strrchr.c [new file with mode: 0644]
test/val/lib_common_strspn.c [new file with mode: 0644]
test/val/lib_common_strtoul.c [new file with mode: 0644]
test/val/lz4.c [new file with mode: 0644]
test/val/postincdec.c [new file with mode: 0644]
test/val/static-fwd-decl.c [new file with mode: 0644]
test/val/strtol-test.c [deleted file]
test/val/strtoul-test.c [deleted file]
test/val/trampoline-params.c [new file with mode: 0644]
test/val/trampoline-varargs.c [new file with mode: 0644]
test/val/trampoline.c [new file with mode: 0644]
test/val/unittest.h [new file with mode: 0644]
test/val/void-size1.c [new file with mode: 0644]
test/val/while.c
testcode/lib/atari/displaylist.c
testcode/lib/conio.c
testcode/lib/gamate/ctest.c
testcode/lib/joy-test.c
testcode/lib/mul-test.c
testcode/lib/pce/conio.c
testcode/lib/strchr-test.c [deleted file]

diff --git a/.gitattributes b/.gitattributes
new file mode 100644 (file)
index 0000000..176a458
--- /dev/null
@@ -0,0 +1 @@
+* text=auto
index 10ea789cf3fbf9616a33db124139758c4643348c..c84eb0cc2dd40702b40ced44755f15ce01e131b8 100644 (file)
@@ -6,13 +6,9 @@ install:
 script:
   - make bin USER_CFLAGS=-Werror
   - make lib QUIET=1
-  - make -C test
+  - make -C test QUIET=1
   - make -C src clean
   - make bin USER_CFLAGS=-Werror CROSS_COMPILE=i686-w64-mingw32-
   - make doc zip
 after_success:
   - make -f Makefile.travis
-env:
-  global:
-    - secure: "h+hoQdEHGPLNwaqGKmSaM8NBRDLc2X+W05VsnNG2Feq/wPv/AiBjONNlzN7jRf6D6f3aoPXaQ2Lc3bYWdxGvFRCmwiofdxkJI9n5L8HPHLZ2lf37MQsXmGJzoTFOvjPLj73H6HlbI9Ux0El3zO6hvalxiXj6TfoZ41dbhNyvpYk="
-    - secure: "A4hMEe5RRfUtYjFGbT7QAvT1Tyo434N+/TiuQeQ4q0L46c79LnXuGQzbFLOFZshZiplLkJr7lFg466CoI1bf2L0cQOew/LesMhE75v0HQ7tZnExWhdpAk0ri6nWixbjn/dmQ0+HxjzJ48A44DMMBYcvSIsO4vflvuJ8etfSg42k="
index 808689c82942be7696a935122e3fc21189901e76..206f853fc98ea1921022895c209f6bbd2c68755c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-.PHONY: all mostlyclean clean install zip avail unavail bin lib doc samples
+.PHONY: all mostlyclean clean install zip avail unavail bin lib doc html info samples
 
 .SUFFIXES:
 
@@ -14,7 +14,7 @@ avail unavail bin:
 lib:
        @$(MAKE) -C libsrc  --no-print-directory $@
 
-doc:
+doc html info:
        @$(MAKE) -C doc     --no-print-directory $@
 
 samples:
index b67c9a8dbf534495415ea01a333f6b7ef703b0a8..91fae4a9a1db30269552842f49aebd67760d7b48 100644 (file)
@@ -8,42 +8,42 @@
 ; ATASCII CHARACTER DEFS
 ;-------------------------------------------------------------------------
  
-ATEOL   = $9B           ;END-OF-LINE, used by CONIO
+ATEOL   = $9B      END-OF-LINE, used by CONIO
 
 
 ;-------------------------------------------------------------------------
 ; Zero Page
 ;-------------------------------------------------------------------------
 
-POKMSK  =  $00   ;Mask for Pokey IRQ enable
-RTCLOK  =  $01   ;60 hz. clock
+POKMSK  =  $00     ; Mask for Pokey IRQ enable
+RTCLOK  =  $01     ; 60 hz. clock
 JUMP    =  $01   
-CRITIC  =  $03   ;Critical section
-ATRACT  =  $04   ;Attract Mode 
-
-SDLSTL  =  $05   ;DLISTL Shadow
-SDLSTH  =  $06   ;DLISTH  "
-SDMCTL  =  $07   ;DMACTL  "
-
-PCOLR0  =  $08   ;COLPM0 Shadow
-PCOLR1  =  $09   ;COLPM1  "
-PCOLR2  =  $0A   ;COLPM2  "
-PCOLR3  =  $0B   ;COLPM3  "
-
-COLOR0  =  $0C   ;COLPF0 Shadow
-COLOR1  =  $0D   ;COLPF1  "
-COLOR2  =  $0E   ;COLPF2  "
-COLOR3  =  $0F   ;COLPF3  "
-COLOR4  =  $10   ;COLBK   "
-
-PADDL0  =  $11   ;POT0 Shadow
-PADDL1  =  $12   ;POT1  "
-PADDL2  =  $13   ;POT2  "
-PADDL3  =  $14   ;POT3  "
-PADDL4  =  $15   ;POT4  "
-PADDL5  =  $16   ;POT5  "
-PADDL6  =  $17   ;POT6  "
-PADDL7  =  $18   ;POT7  "
+CRITIC  =  $03     ; Critical section
+ATRACT  =  $04     ; Attract Mode 
+
+SDLSTL  =  $05     ; DLISTL Shadow
+SDLSTH  =  $06     ; DLISTH  "
+SDMCTL  =  $07     ; DMACTL  "
+
+PCOLR0  =  $08     ; COLPM0 Shadow
+PCOLR1  =  $09     ; COLPM1  "
+PCOLR2  =  $0A     ; COLPM2  "
+PCOLR3  =  $0B     ; COLPM3  "
+
+COLOR0  =  $0C     ; COLPF0 Shadow
+COLOR1  =  $0D     ; COLPF1  "
+COLOR2  =  $0E     ; COLPF2  "
+COLOR3  =  $0F     ; COLPF3  "
+COLOR4  =  $10     ; COLBK   "
+
+PADDL0  =  $11     ; POT0 Shadow
+PADDL1  =  $12     ; POT1  "
+PADDL2  =  $13     ; POT2  "
+PADDL3  =  $14     ; POT3  "
+PADDL4  =  $15     ; POT4  "
+PADDL5  =  $16     ; POT5  "
+PADDL6  =  $17     ; POT6  "
+PADDL7  =  $18     ; POT7  "
 
 ; cc65 runtime zero page variables
 
@@ -57,26 +57,26 @@ SAVMSC          =       $1B             ; pointer to screen memory (conio)
 
 ;Interrupt Vectors
                  
-VIMIRQ  =  $0200   ;Immediate IRQ    
-                      ;Preset $FC03 (SYSIRQ)
-VVBLKI  =  $0202   ;Vblank immediate
-                      ;Preset $FCB8 (SYSVBL)
-VVBLKD  =  $0204   ;Vblank deferred
-                      ;Preset $FCB2 (XITVBL)
-VDSLST  =  $0206   ;Display List 
-                      ;Preset $FEA1 (OSDLI)
-VKYBDI  =  $0208   ;Keyboard immediate
-                      ;Preset $FD02 (SYSKBD)
-VKYBDF  =  $020A   ;Deferred Keyboard
-                      ;Preset $FCB2 (XITVBL)
-VTRIGR  =  $020C   ;Soft Trigger   
-VBRKOP  =  $020E   ;BRK Opcode
-VSERIN  =  $0210   ;Serial in Ready
-VSEROR  =  $0212   ;Serial Out Ready
-VSEROC  =  $0214   ;Serial Output complete
-VTIMR1  =  $0216   ;Pokey Timer 1
-VTIMR2  =  $0218   ;Pokey Timer 2
-VTIMR4  =  $021A   ;Pokey Timer 4
+VIMIRQ  =  $0200   ; Immediate IRQ    
+                      ; Preset $FC03 (SYSIRQ)
+VVBLKI  =  $0202   ; Vblank immediate
+                      ; Preset $FCB8 (SYSVBL)
+VVBLKD  =  $0204   ; Vblank deferred
+                      ; Preset $FCB2 (XITVBL)
+VDSLST  =  $0206   ; Display List 
+                      ; Preset $FEA1 (OSDLI)
+VKYBDI  =  $0208   ; Keyboard immediate
+                      ; Preset $FD02 (SYSKBD)
+VKYBDF  =  $020A   ; Deferred Keyboard
+                      ; Preset $FCB2 (XITVBL)
+VTRIGR  =  $020C   ; Soft Trigger   
+VBRKOP  =  $020E   ; BRK Opcode
+VSERIN  =  $0210   ; Serial in Ready
+VSEROR  =  $0212   ; Serial Out Ready
+VSEROC  =  $0214   ; Serial Output complete
+VTIMR1  =  $0216   ; Pokey Timer 1
+VTIMR2  =  $0218   ; Pokey Timer 2
+VTIMR4  =  $021A   ; Pokey Timer 4
 
 
 
@@ -84,21 +84,21 @@ VTIMR4  =  $021A   ;Pokey Timer 4
 ; CTIA/GTIA Address Equates
 ;-------------------------------------------------------------------------
 
-GTIA    = $C000         ;CTIA/GTIA area
+GTIA    = $C000    CTIA/GTIA area
 .include "atari_gtia.inc"
 
 ;-------------------------------------------------------------------------
 ; ANTIC Address Equates
 ;-------------------------------------------------------------------------
 
-ANTIC     = $D400         ;ANTIC area
+ANTIC     = $D400  ANTIC area
 .include  "atari_antic.inc"
 
 ;-------------------------------------------------------------------------
 ; POKEY Address Equates
 ;-------------------------------------------------------------------------
 
-POKEY     = $E800         ;POKEY area
+POKEY     = $E800  POKEY area
 .include  "atari_pokey.inc"
 
 
@@ -106,11 +106,10 @@ POKEY     = $E800         ;POKEY area
 ; Cartridge Parameters
 ;-------------------------------------------------------------------------
 
-CARTNM  =  $BFE8   ;Cartridge Name Area
-COPYD   =  $BFFC   ;Copyright Decade in Cart
-COPYR   =  $BFFD   ;Copyright Year in Cart
+CARTNM  =  $BFE8   ; Cartridge Name Area
+COPYD   =  $BFFC   ; Copyright Decade in Cart
+COPYR   =  $BFFD   ; Copyright Year in Cart
                       ; $FF=Diagnostic Cart
-GOCART  =  $BFFE   ;Cartridge Start Vector
+GOCART  =  $BFFE   ; Cartridge Start Vector
 
-
-CHRORG  =  $F800   ;Character Generator Base
+CHRORG  =  $F800   ; Character Generator Base
index e6c89b07b021939896ad8d7e76657f77838f8fd8..9e9acc5a85a0d031cf0ce89f6d96035ea250812e 100644 (file)
@@ -38,6 +38,10 @@ INIT_STATUS     := $A04         ; Flags: Reset/Restore initiation status
 FKEY_LEN        := $1000        ; Function key lengths
 FKEY_TEXT       := $100A        ; Function key texts
 
+KBDREPEAT       := $28a
+KBDREPEATRATE   := $28b
+KBDREPEATDELAY  := $28c
+
 ; ---------------------------------------------------------------------------
 ; Kernal routines
 
index ababb1ea0cdc2f933535237aa79aa39747811e57..00b66a64f49639e5166840296106264eef637958 100644 (file)
@@ -33,6 +33,9 @@ CHARCOLOR       := $286
 CURS_COLOR      := $287         ; Color under the cursor
 PALFLAG         := $2A6         ; $01 = PAL, $00 = NTSC
 
+KBDREPEAT       := $28a
+KBDREPEATRATE   := $28b
+KBDREPEATDELAY  := $28c
 
 ; ---------------------------------------------------------------------------
 ; Kernal routines
index 59b26101bbfcf9ce89b3aed80ad7a314aa930b00..49d55a3425362572563cda823af5d728bffa9d8c 100644 (file)
@@ -10,10 +10,10 @@ CURSOR_X                = $3C
 CURSOR_Y                = $3D
 
 ;** VDP
-VDP_CONTROL_W           = $3001
-VDP_DATA_W              = $3000
-VDP_STATUS_R            = $2001
 VDP_DATA_R              = $2000
+VDP_STATUS_R            = $2001
+VDP_DATA_W              = $3000
+VDP_CONTROL_W           = $3001
 
 ;** PIA
 PIA0_DATA               = $1000
@@ -36,7 +36,26 @@ ZP_JOY1_DIR             = $13
 ZP_JOY0_BUTTONS         = $16
 ZP_JOY1_BUTTONS         = $17
 
+;** Joystick direction values (ZP_JOY0_DIR/ZP_JOY1_DIR)
+JOY_N                   = $49
+JOY_NNE                 = $48
+JOY_NE                  = $47
+JOY_ENE                 = $46
+JOY_E                   = $45
+JOY_ESE                 = $44
+JOY_SE                  = $43
+JOY_SSE                 = $42
+JOY_S                   = $41
+JOY_SSW                 = $40
+JOY_SW                  = $4F
+JOY_WSW                 = $4E
+JOY_W                   = $4D
+JOY_WNW                 = $4C
+JOY_NW                  = $4B
+JOY_NNW                 = $4A
+
 ;** BIOS
 BIOS_IRQ1_ADDR          = $FF3F
 BIOS_IRQ2_ADDR          = $FF52
 BIOS_NMI_RESET_ADDR     = $F808
+BIOS_WRITE_VDP_REG      = $FE1F
index 4fe5572cf0b843c9d4a6e05bd63db59216bd3004..ba969da1d36618510cbeb414eb87a1e6b4ba30d0 100644 (file)
@@ -43,7 +43,6 @@
         ID      .byte   3       ; $6A, $6F, $79 ("joy")
         VERSION .byte   1       ; Interface version
         LIBREF  .addr           ; Library reference
-        MASKS   .byte   8       ; Joystick state mask array
         JUMPTAB .struct
             INSTALL     .addr   ; INSTALL routine
             UNINSTALL   .addr   ; UNINSTALL routine
index 7c52871d2afbb01cc06b5910361c22286a0ead26..96cdefb65e2e99f640fa69bf743d27b4a01381aa 100644 (file)
-; opcodes.inc\r
-; ca65 6502 - opcode definitions, mainly for self modifying code\r
-;\r
-; Christian Krüger, latest change: 18-Sep-2010\r
-;\r
-; This software is provided 'as-is', without any expressed or implied      \r
-; warranty.  In no event will the authors be held liable for any damages   \r
-; arising from the use of this software.                                   \r
-;                                                                          \r
-; Permission is granted to anyone to use this software for any purpose,    \r
-; including commercial applications, and to alter it and redistribute it   \r
-; freely, subject to the following restrictions:                           \r
-;                                                                          \r
-; 1. The origin of this software must not be misrepresented; you must not  \r
-;    claim that you wrote the original software. If you use this software  \r
-;    in a product, an acknowledgment in the product documentation would be \r
-;    appreciated but is not required.                                      \r
-; 2. Altered source versions must be plainly marked as such, and must not  \r
-;    be misrepresented as being the original software.                     \r
-; 3. This notice may not be removed or altered from any source             \r
-;    distribution.                                                         \r
-;                                                                          \r
-\r
-; Opcode-Table\r
-; ------------\r
-; Post fix explanation:\r
-; imm = #$00\r
-; zp = $00\r
-; zpx = $00,X\r
-; zpy = $00,Y\r
-; izp = ($00)\r
-; izx = ($00,X)\r
-; izy = ($00),Y\r
-; abs = $0000\r
-; abx = $0000,X\r
-; aby = $0000,Y\r
-; ind = ($0000)\r
-; iax = ($0000,X)\r
-; rel = $0000 (PC-relative) (supressed here)\r
-\r
-.macpack        cpu\r
-\r
-OPC_BRK     = $00\r
-OPC_ORA_izx = $01\r
-OPC_ORA_zp  = $05\r
-OPC_ASL_zp  = $06\r
-OPC_PHP     = $08\r
-OPC_ORA_imm = $09\r
-OPC_ASL     = $0A\r
-OPC_ORA_abs = $0D\r
-OPC_ASL_abs = $0E\r
-\r
-OPC_BPL     = $10\r
-OPC_ORA_izy = $11\r
-OPC_ORA_zpx = $15\r
-OPC_ASL_zpx = $16\r
-OPC_CLC     = $18\r
-OPC_ORA_aby = $19\r
-OPC_ORA_abx = $1D\r
-OPC_ASL_abx = $1E\r
-\r
-OPC_JSR_abs = $20\r
-OPC_AND_izx = $21\r
-OPC_BIT_zp  = $24\r
-OPC_AND_zp  = $25\r
-OPC_ROL_zp  = $26\r
-OPC_PLP     = $28\r
-OPC_AND_imm = $29\r
-OPC_ROL     = $2A\r
-OPC_BIT_abs = $2C\r
-OPC_AND_abs = $2D\r
-OPC_ROL_abs = $2E\r
-\r
-OPC_BMI     = $30\r
-OPC_AND_izy = $31\r
-OPC_AND_zpx = $35\r
-OPC_ROL_zpx = $36\r
-OPC_SEC     = $38\r
-OPC_AND_aby = $39\r
-OPC_AND_abx = $3D\r
-OPC_ROL_abx = $3E\r
-\r
-\r
-OPC_RTI     = $40\r
-OPC_EOR_izx = $41\r
-OPC_EOR_zp  = $45\r
-OPC_LSR_zp  = $46\r
-OPC_PHA     = $48\r
-OPC_EOR_imm = $49\r
-OPC_LSR     = $4A\r
-OPC_JMP_abs = $4C\r
-OPC_EOR_abs = $4D\r
-OPC_LSR_abs = $4E\r
-\r
-OPC_BVC     = $50\r
-OPC_EOR_izy = $51\r
-OPC_EOR_zpx = $55\r
-OPC_LSR_zpx = $56\r
-OPC_CLI     = $58\r
-OPC_EOR_aby = $59\r
-OPC_EOR_abx = $5D\r
-OPC_LSR_abx = $5E\r
-\r
-OPC_RTS     = $60\r
-OPC_ADC_izx = $61\r
-OPC_ADC_zp  = $65\r
-OPC_ROR_zp  = $66\r
-OPC_PLA     = $68\r
-OPC_ADC_imm = $69\r
-OPC_ROR     = $6A\r
-OPC_JMP_ind = $6C\r
-OPC_ADC_abs = $6D\r
-OPC_ROR_abs = $6E\r
-\r
-OPC_BVS     = $70\r
-OPC_ADC_izy = $71\r
-OPC_ADC_zpx = $75\r
-OPC_ROR_zpx = $76\r
-OPC_SEI     = $78\r
-OPC_ADC_aby = $79\r
-OPC_ADC_abx = $7D\r
-OPC_ROR_abx = $7E\r
-\r
-OPC_STA_izx = $81\r
-OPC_STY_zp  = $84\r
-OPC_STA_zp  = $85\r
-OPC_STX_zp  = $86\r
-OPC_DEY     = $88\r
-OPC_TXA     = $8A\r
-OPC_STY_abs = $8C\r
-OPC_STA_abs = $8D\r
-OPC_STX_abs = $8E\r
-\r
-OPC_BCC     = $90\r
-OPC_STA_izy = $91\r
-OPC_STY_zpx = $94\r
-OPC_STA_zpx = $95\r
-OPC_STX_zpy = $96\r
-OPC_TYA     = $98\r
-OPC_STA_aby = $99\r
-OPC_TXS     = $9A\r
-OPC_STA_abx = $9D\r
-\r
-OPC_LDY_imm = $A0\r
-OPC_LDA_izx = $A1\r
-OPC_LDX_imm = $A2\r
-OPC_LDY_zp  = $A4\r
-OPC_LDA_zp  = $A5\r
-OPC_LDX_zp  = $A6\r
-OPC_TAY     = $A8\r
-OPC_LDA_imm = $A9\r
-OPC_TAX     = $AA\r
-OPC_LDY_abs = $AC\r
-OPC_LDA_abs = $AD\r
-OPC_LDX_abs = $AE\r
-\r
-OPC_BCS     = $B0\r
-OPC_LDA_izy = $B1\r
-OPC_LDY_zpx = $B4\r
-OPC_LDA_zpx = $B5\r
-OPC_LDX_zpy = $B6\r
-OPC_CLV     = $B8\r
-OPC_LDA_aby = $B9\r
-OPC_TSX     = $BA\r
-OPC_LDY_abx = $BC\r
-OPC_LDA_abx = $BD\r
-OPC_LDX_aby = $BE\r
-\r
-OPC_CPY_imm = $C0\r
-OPC_CMP_izx = $C1\r
-OPC_CPY_zp  = $C4\r
-OPC_CMP_zp  = $C5\r
-OPC_DEC_zp  = $C6\r
-OPC_INY     = $C8\r
-OPC_CMP_imm = $C9\r
-OPC_DEX     = $CA\r
-OPC_CPY_abs = $CC\r
-OPC_CMP_abs = $CD\r
-OPC_DEC_abs = $CE\r
-\r
-OPC_BNE     = $D0\r
-OPC_CMP_izy = $D1\r
-OPC_CMP_zpx = $D5\r
-OPC_DEC_zpx = $D6\r
-OPC_CLD     = $D8\r
-OPC_CMP_aby = $D9\r
-OPC_CMP_abx = $DD\r
-OPC_DEC_abx = $DE\r
-\r
-OPC_CPX_imm = $E0\r
-OPC_SBC_izx = $E1\r
-OPC_CPX_zp  = $E4\r
-OPC_SBC_zp  = $E5\r
-OPC_INC_zp  = $E6\r
-OPC_INX     = $E8\r
-OPC_SBC_imm = $E9\r
-OPC_NOP     = $EA\r
-OPC_CPX_abs = $EC\r
-OPC_SBC_abs = $ED\r
-OPC_INC_abs = $EE\r
-\r
-\r
-OPC_BEQ     = $F0\r
-OPC_SBC_izy = $F1\r
-OPC_SBC_zpx = $F5\r
-OPC_INC_zpx = $F6\r
-OPC_SED     = $F8\r
-OPC_SBC_aby = $F9\r
-OPC_SBC_abx = $FD\r
-OPC_INC_abx = $FE\r
-\r
-\r
-.if (.cpu .bitand ::CPU_ISET_65SC02)\r
-\r
-; OPC_NOP   = $02               ; doublet\r
-; OPC_NOP   = $03               ; doublet\r
-OPC_TSB_zp  = $04\r
-; OPC_NOP   = $0B               ; doublet\r
-OPC_TSB_abs = $0C\r
-\r
-OPC_ORA_izp = $12\r
-; OPC_NOP   = $13               ; doublet\r
-OPC_TRB_zp  = $14\r
-OPC_INC     = $1A\r
-; OPC_NOP   = $1B               ; doublet\r
-OPC_TRB_abs = $1C\r
-\r
-; OPC_NOP   = $22               ; doublet\r
-; OPC_NOP   = $23               ; doublet\r
-; OPC_NOP   = $2B               ; doublet\r
-\r
-OPC_AND_izp = $32\r
-; OPC_NOP   = $33               ; doublet\r
-OPC_BIT_zpx = $34\r
-OPC_DEC     = $3A\r
-; OPC_NOP   = $3B               ; doublet\r
-OPC_BIT_abx = $3C\r
-\r
-; OPC_NOP   = $42               ; doublet\r
-; OPC_NOP   = $43               ; doublet\r
-; OPC_NOP   = $44               ; doublet\r
-; OPC_NOP   = $4B               ; doublet\r
-\r
-OPC_EOR_izp = $52               \r
-; OPC_NOP   = $53               ; doublet\r
-; OPC_NOP   = $54               ; doublet\r
-; OPC_NOP   = $5A               ; doublet\r
-; OPC_NOP   = $5B               ; doublet\r
-OPC_EOR_abx = $5C\r
-\r
-; OPC_NOP   = $62               ; doublet\r
-; OPC_NOP   = $63               ; doublet\r
-OPC_STZ_zp  = $64\r
-; OPC_NOP   = $6B               ; doublet\r
-\r
-OPC_ADC_izp = $72\r
-; OPC_NOP   = $73               ; doublet\r
-OPC_STZ_zpx = $74\r
-OPC_PLY     = $7A\r
-; OPC_NOP   = $7B               ; doublet\r
-OPC_JMP_iax = $7C\r
-\r
-OPC_BRA     = $80\r
-; OPC_NOP   = $82               ; doublet\r
-; OPC_NOP   = $83               ; doublet\r
-OPC_BIT_imm = $89\r
-; OPC_NOP   = $8B               ; doublet\r
-\r
-OPC_STA_izp = $92\r
-; OPC_NOP   = $93               ; doublet\r
-; OPC_NOP   = $9B               ; doublet\r
-OPC_STZ_abs = $9C\r
-OPC_STZ_abx = $9E\r
-\r
-; OPC_NOP   = $A3               ; doublet\r
-; OPC_NOP   = $AB               ; doublet\r
-\r
-OPC_LDA_izp = $B2\r
-; OPC_NOP   = $B3               ; doublet\r
-; OPC_NOP   = $BB               ; doublet\r
-\r
-; OPC_NOP   = $C2               ; doublet\r
-; OPC_NOP   = $C3               ; doublet\r
-; OPC_NOP   = $CB               ; doublet\r
-\r
-OPC_CMP_izp = $D2\r
-; OPC_NOP   = $D3               ; doublet\r
-; OPC_NOP   = $D4               ; doublet\r
-OPC_PHX     = $DA\r
-; OPC_NOP   = $DB               ; doublet\r
-; OPC_NOP   = $DC               ; doublet\r
-\r
-; OPC_NOP   = $E2               ; doublet\r
-; OPC_NOP   = $E3               ; doublet\r
-; OPC_NOP   = $EB               ; doublet\r
-\r
-OPC_SBC_izp = $F2\r
-; OPC_NOP   = $F3               ; doublet\r
-; OPC_NOP   = $F4               ; doublet\r
-OPC_PLX     = $FA\r
-; OPC_NOP   = $FB               ; doublet\r
-; OPC_NOP   = $FC               ; doublet\r
-\r
-\r
-.if (.cpu .bitand ::CPU_ISET_65C02)\r
-\r
-; bit instructions for 65C02\r
-\r
-OPC_RMB0    = $07\r
-OPC_RMB1    = $17\r
-OPC_RMB2    = $27\r
-OPC_RMB3    = $37\r
-OPC_RMB4    = $47\r
-OPC_RMB5    = $57\r
-OPC_RMB6    = $67\r
-OPC_RMB7    = $77\r
-\r
-OPC_SMB0    = $87\r
-OPC_SMB1    = $97\r
-OPC_SMB2    = $A7\r
-OPC_SMB3    = $B7\r
-OPC_SMB4    = $C7\r
-OPC_SMB5    = $D7\r
-OPC_SMB6    = $E7\r
-OPC_SMB7    = $F7\r
-\r
-OPC_BBR0    = $0F\r
-OPC_BBR1    = $1F\r
-OPC_BBR2    = $2F\r
-OPC_BBR3    = $3F\r
-OPC_BBR4    = $4F\r
-OPC_BBR5    = $5F\r
-OPC_BBR6    = $6F\r
-OPC_BBR7    = $7F\r
-\r
-OPC_BBS0    = $8F\r
-OPC_BBS1    = $9F\r
-OPC_BBS2    = $AF\r
-OPC_BBS3    = $BF\r
-OPC_BBS4    = $CF\r
-OPC_BBS5    = $DF\r
-OPC_BBS6    = $EF\r
-OPC_BBS7    = $FF\r
-\r
-.else\r
-\r
-; no bit instructions for 65SC02\r
-\r
-; OPC_NOP   = $07               ; doublet\r
-; OPC_NOP   = $17               ; doublet\r
-; OPC_NOP   = $27               ; doublet\r
-; OPC_NOP   = $37               ; doublet\r
-; OPC_NOP   = $47               ; doublet\r
-; OPC_NOP   = $57               ; doublet\r
-; OPC_NOP   = $67               ; doublet\r
-; OPC_NOP   = $77               ; doublet\r
-; OPC_NOP   = $87               ; doublet\r
-; OPC_NOP   = $97               ; doublet\r
-; OPC_NOP   = $A7               ; doublet\r
-; OPC_NOP   = $B7               ; doublet\r
-; OPC_NOP   = $C7               ; doublet\r
-; OPC_NOP   = $D7               ; doublet\r
-; OPC_NOP   = $E7               ; doublet\r
-; OPC_NOP   = $F7               ; doublet\r
-; OPC_NOP   = $0F               ; doublet\r
-; OPC_NOP   = $1F               ; doublet\r
-; OPC_NOP   = $2F               ; doublet\r
-; OPC_NOP   = $3F               ; doublet\r
-; OPC_NOP   = $4F               ; doublet\r
-; OPC_NOP   = $5F               ; doublet\r
-; OPC_NOP   = $6F               ; doublet\r
-; OPC_NOP   = $7F               ; doublet\r
-; OPC_NOP   = $8F               ; doublet\r
-; OPC_NOP   = $9F               ; doublet\r
-; OPC_NOP   = $AF               ; doublet\r
-; OPC_NOP   = $BF               ; doublet\r
-; OPC_NOP   = $CF               ; doublet\r
-; OPC_NOP   = $DF               ; doublet\r
-; OPC_NOP   = $EF               ; doublet\r
-; OPC_NOP   = $FF               ; doublet\r
-\r
-.endif\r
-\r
-.elseif (.cpu .bitand ::CPU_ISET_6502X)\r
-\r
-; stable, undocumented opcodes\r
-\r
-; OPC_KIL   = $02               ; unstable\r
-OPC_SLO_izx = $03\r
-OPC_NOP_zp  = $04\r
-OPC_SLO_zp  = $07\r
-OPC_ANC_imm = $0B\r
-OPC_NOP_abs = $0C\r
-OPC_SLO_abs = $0F\r
-\r
-; OPC_KIL   = $12               ; unstable\r
-OPC_SLO_izy = $13\r
-OPC_NOP_zpx = $14\r
-OPC_SLO_zpx = $17\r
-;OPC_NOP    = $1A\r
-OPC_SLO_aby = $1B\r
-OPC_NOP_abx = $1C\r
-OPC_SLO_abx = $1F\r
-\r
-; OPC_KIL   = $22               ; unstable\r
-OPC_RLA_izx = $23\r
-OPC_RLA_zp  = $27\r
-OPC_ANC_imm = $2B\r
-OPC_RLA_abs = $2F\r
-\r
-; OPC_KIL   = $32               ; unstable\r
-OPC_RLA_izy = $33\r
-OPC_NOP_zpx = $34\r
-OPC_RLA_zpx = $37\r
-; OPC_NOP   = $3A               ; doublet\r
-OPC_RLA_aby = $3B\r
-OPC_NOP_abx = $3C\r
-OPC_RLA_abx = $3F\r
-\r
-; OPC_KIL   = $42               ; unstable\r
-OPC_SRE_izx = $43\r
-OPC_NOP_zp  = $44\r
-OPC_SRE_zp  = $47\r
-OPC_ALR_imm = $4B\r
-OPC_SRE_abs = $4F\r
-\r
-; OPC_KIL   = $52               ; unstable\r
-OPC_SRE_izy = $53\r
-OPC_NOP_zpx = $54\r
-OPC_SRE_zpx = $57\r
-; OPC_NOP   = $5A               ; doublet\r
-OPC_SRE_aby = $5B\r
-OPC_NOP_abx = $5C\r
-OPC_SRE_abx = $5F\r
-\r
-; OPC_KIL   = $62\r
-OPC_RRA_izx = $63\r
-OPC_NOP_zp  = $64\r
-OPC_RRA_zp  = $67\r
-OPC_ARR_imm = $6B\r
-OPC_RRA_abs = $6F\r
-\r
-; OPC_KIL   = $72\r
-OPC_RRA_izy = $73\r
-OPC_NOP_zpx = $74\r
-OPC_RRA_zpx = $77\r
-; OPC_NOP   = $7A               ; doublet\r
-OPC_RRA_aby = $7B\r
-OPC_NOP_abx = $7C\r
-OPC_RRA_abx = $7F\r
-\r
-OPC_NOP_imm = $80\r
-; OPC_NOP_imm = $82             ; doublet\r
-OPC_SAX_izx = $83\r
-OPC_SAX_zp  = $87\r
-; OPC_NOP_imm = $89             ; doublet\r
-; OPC_XAA = $8B                 ; unstable\r
-OPC_SAX_abs = $8F\r
-\r
-; OPC_KIL   = $92               ; unstable\r
-; OPC_AHX_izy = $93             ; unstable\r
-OPC_SAX_zpy = $97\r
-; OPC_TAS_aby = $9B             ; unstable\r
-; OPC_SHY_abx = $9C             ; unstable\r
-; OPC_SHX_aby = $9E             ; unstable\r
-; OPC_AHX_aby = $9F             ; unstable\r
-\r
-OPC_LAX_izx = $A3\r
-OPC_LAX_zp  = $A7\r
-; OPC_LAX_imm = $AB             ; unstable\r
-OPC_LAX_abs = $AF\r
-\r
-; OPC_KIL   = $B2               ; unstable\r
-OPC_LAX_izy = $B3\r
-OPC_LAX_zpy = $B7\r
-OPC_LAS_aby = $BB\r
-OPC_LAX_aby = $BF\r
-\r
-; OPC_NOP_imm = $C2             ; doublet\r
-OPC_DCP_izx = $C3\r
-OPC_DCP_zp  = $C7\r
-OPC_AXS_imm = $CB\r
-OPC_DCP_abs = $CF\r
-\r
-; OPC_KIL   = $D2               ; unstable\r
-OPC_DCP_izy = $D3\r
-OPC_NOP_zpx = $D4\r
-OPC_DCP_zpx = $D7\r
-OPC_NOP_DA  = $DA\r
-OPC_DCP_aby = $DB\r
-OPC_NOP_abx = $DC\r
-OPC_DCP_abx = $DF\r
-\r
-; OPC_NOP_imm = $E2             ; doublet\r
-OPC_ISC_izx = $E3\r
-OPC_ISC_zp  = $E7\r
-; OPC_SBC_imm = $EB             ; doublet\r
-OPC_ISC_abs = $EF\r
-\r
-; OPC_KIL   = $F2               ; unstable\r
-OPC_ISC_izy = $F3\r
-OPC_NOP_zpx = $F4\r
-OPC_ISC_zpx = $F7\r
-OPC_NOP_FA  = $FA\r
-OPC_ISC_aby = $FB\r
-OPC_NOP_abx = $FC\r
-OPC_ISC_abx = $FF\r
-\r
-.endif\r
+; opcodes.inc
+; ca65 6502 - opcode definitions, mainly for self modifying code
+;
+; Christian Krüger, latest change: 18-Sep-2010
+;
+; 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.                                                         
+;                                                                          
+
+; Opcode-Table
+; ------------
+; Post fix explanation:
+; imm = #$00
+; zp = $00
+; zpx = $00,X
+; zpy = $00,Y
+; izp = ($00)
+; izx = ($00,X)
+; izy = ($00),Y
+; abs = $0000
+; abx = $0000,X
+; aby = $0000,Y
+; ind = ($0000)
+; iax = ($0000,X)
+; rel = $0000 (PC-relative) (supressed here)
+
+.macpack        cpu
+
+OPC_BRK     = $00
+OPC_ORA_izx = $01
+OPC_ORA_zp  = $05
+OPC_ASL_zp  = $06
+OPC_PHP     = $08
+OPC_ORA_imm = $09
+OPC_ASL     = $0A
+OPC_ORA_abs = $0D
+OPC_ASL_abs = $0E
+
+OPC_BPL     = $10
+OPC_ORA_izy = $11
+OPC_ORA_zpx = $15
+OPC_ASL_zpx = $16
+OPC_CLC     = $18
+OPC_ORA_aby = $19
+OPC_ORA_abx = $1D
+OPC_ASL_abx = $1E
+
+OPC_JSR_abs = $20
+OPC_AND_izx = $21
+OPC_BIT_zp  = $24
+OPC_AND_zp  = $25
+OPC_ROL_zp  = $26
+OPC_PLP     = $28
+OPC_AND_imm = $29
+OPC_ROL     = $2A
+OPC_BIT_abs = $2C
+OPC_AND_abs = $2D
+OPC_ROL_abs = $2E
+
+OPC_BMI     = $30
+OPC_AND_izy = $31
+OPC_AND_zpx = $35
+OPC_ROL_zpx = $36
+OPC_SEC     = $38
+OPC_AND_aby = $39
+OPC_AND_abx = $3D
+OPC_ROL_abx = $3E
+
+
+OPC_RTI     = $40
+OPC_EOR_izx = $41
+OPC_EOR_zp  = $45
+OPC_LSR_zp  = $46
+OPC_PHA     = $48
+OPC_EOR_imm = $49
+OPC_LSR     = $4A
+OPC_JMP_abs = $4C
+OPC_EOR_abs = $4D
+OPC_LSR_abs = $4E
+
+OPC_BVC     = $50
+OPC_EOR_izy = $51
+OPC_EOR_zpx = $55
+OPC_LSR_zpx = $56
+OPC_CLI     = $58
+OPC_EOR_aby = $59
+OPC_EOR_abx = $5D
+OPC_LSR_abx = $5E
+
+OPC_RTS     = $60
+OPC_ADC_izx = $61
+OPC_ADC_zp  = $65
+OPC_ROR_zp  = $66
+OPC_PLA     = $68
+OPC_ADC_imm = $69
+OPC_ROR     = $6A
+OPC_JMP_ind = $6C
+OPC_ADC_abs = $6D
+OPC_ROR_abs = $6E
+
+OPC_BVS     = $70
+OPC_ADC_izy = $71
+OPC_ADC_zpx = $75
+OPC_ROR_zpx = $76
+OPC_SEI     = $78
+OPC_ADC_aby = $79
+OPC_ADC_abx = $7D
+OPC_ROR_abx = $7E
+
+OPC_STA_izx = $81
+OPC_STY_zp  = $84
+OPC_STA_zp  = $85
+OPC_STX_zp  = $86
+OPC_DEY     = $88
+OPC_TXA     = $8A
+OPC_STY_abs = $8C
+OPC_STA_abs = $8D
+OPC_STX_abs = $8E
+
+OPC_BCC     = $90
+OPC_STA_izy = $91
+OPC_STY_zpx = $94
+OPC_STA_zpx = $95
+OPC_STX_zpy = $96
+OPC_TYA     = $98
+OPC_STA_aby = $99
+OPC_TXS     = $9A
+OPC_STA_abx = $9D
+
+OPC_LDY_imm = $A0
+OPC_LDA_izx = $A1
+OPC_LDX_imm = $A2
+OPC_LDY_zp  = $A4
+OPC_LDA_zp  = $A5
+OPC_LDX_zp  = $A6
+OPC_TAY     = $A8
+OPC_LDA_imm = $A9
+OPC_TAX     = $AA
+OPC_LDY_abs = $AC
+OPC_LDA_abs = $AD
+OPC_LDX_abs = $AE
+
+OPC_BCS     = $B0
+OPC_LDA_izy = $B1
+OPC_LDY_zpx = $B4
+OPC_LDA_zpx = $B5
+OPC_LDX_zpy = $B6
+OPC_CLV     = $B8
+OPC_LDA_aby = $B9
+OPC_TSX     = $BA
+OPC_LDY_abx = $BC
+OPC_LDA_abx = $BD
+OPC_LDX_aby = $BE
+
+OPC_CPY_imm = $C0
+OPC_CMP_izx = $C1
+OPC_CPY_zp  = $C4
+OPC_CMP_zp  = $C5
+OPC_DEC_zp  = $C6
+OPC_INY     = $C8
+OPC_CMP_imm = $C9
+OPC_DEX     = $CA
+OPC_CPY_abs = $CC
+OPC_CMP_abs = $CD
+OPC_DEC_abs = $CE
+
+OPC_BNE     = $D0
+OPC_CMP_izy = $D1
+OPC_CMP_zpx = $D5
+OPC_DEC_zpx = $D6
+OPC_CLD     = $D8
+OPC_CMP_aby = $D9
+OPC_CMP_abx = $DD
+OPC_DEC_abx = $DE
+
+OPC_CPX_imm = $E0
+OPC_SBC_izx = $E1
+OPC_CPX_zp  = $E4
+OPC_SBC_zp  = $E5
+OPC_INC_zp  = $E6
+OPC_INX     = $E8
+OPC_SBC_imm = $E9
+OPC_NOP     = $EA
+OPC_CPX_abs = $EC
+OPC_SBC_abs = $ED
+OPC_INC_abs = $EE
+
+
+OPC_BEQ     = $F0
+OPC_SBC_izy = $F1
+OPC_SBC_zpx = $F5
+OPC_INC_zpx = $F6
+OPC_SED     = $F8
+OPC_SBC_aby = $F9
+OPC_SBC_abx = $FD
+OPC_INC_abx = $FE
+
+
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+
+; OPC_NOP   = $02               ; doublet
+; OPC_NOP   = $03               ; doublet
+OPC_TSB_zp  = $04
+; OPC_NOP   = $0B               ; doublet
+OPC_TSB_abs = $0C
+
+OPC_ORA_izp = $12
+; OPC_NOP   = $13               ; doublet
+OPC_TRB_zp  = $14
+OPC_INC     = $1A
+; OPC_NOP   = $1B               ; doublet
+OPC_TRB_abs = $1C
+
+; OPC_NOP   = $22               ; doublet
+; OPC_NOP   = $23               ; doublet
+; OPC_NOP   = $2B               ; doublet
+
+OPC_AND_izp = $32
+; OPC_NOP   = $33               ; doublet
+OPC_BIT_zpx = $34
+OPC_DEC     = $3A
+; OPC_NOP   = $3B               ; doublet
+OPC_BIT_abx = $3C
+
+; OPC_NOP   = $42               ; doublet
+; OPC_NOP   = $43               ; doublet
+; OPC_NOP   = $44               ; doublet
+; OPC_NOP   = $4B               ; doublet
+
+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
+OPC_STZ_zp  = $64
+; OPC_NOP   = $6B               ; doublet
+
+OPC_ADC_izp = $72
+; OPC_NOP   = $73               ; doublet
+OPC_STZ_zpx = $74
+OPC_PLY     = $7A
+; OPC_NOP   = $7B               ; doublet
+OPC_JMP_iax = $7C
+
+OPC_BRA     = $80
+; OPC_NOP   = $82               ; doublet
+; OPC_NOP   = $83               ; doublet
+OPC_BIT_imm = $89
+; OPC_NOP   = $8B               ; doublet
+
+OPC_STA_izp = $92
+; OPC_NOP   = $93               ; doublet
+; OPC_NOP   = $9B               ; doublet
+OPC_STZ_abs = $9C
+OPC_STZ_abx = $9E
+
+; OPC_NOP   = $A3               ; doublet
+; OPC_NOP   = $AB               ; doublet
+
+OPC_LDA_izp = $B2
+; OPC_NOP   = $B3               ; doublet
+; OPC_NOP   = $BB               ; doublet
+
+; OPC_NOP   = $C2               ; doublet
+; OPC_NOP   = $C3               ; doublet
+; OPC_NOP   = $CB               ; doublet
+
+OPC_CMP_izp = $D2
+; OPC_NOP   = $D3               ; doublet
+; OPC_NOP   = $D4               ; doublet
+OPC_PHX     = $DA
+; OPC_NOP   = $DB               ; doublet
+; OPC_NOP   = $DC               ; doublet
+
+; OPC_NOP   = $E2               ; doublet
+; OPC_NOP   = $E3               ; doublet
+; OPC_NOP   = $EB               ; doublet
+
+OPC_SBC_izp = $F2
+; OPC_NOP   = $F3               ; doublet
+; OPC_NOP   = $F4               ; doublet
+OPC_PLX     = $FA
+; OPC_NOP   = $FB               ; doublet
+; OPC_NOP   = $FC               ; doublet
+
+
+.if (.cpu .bitand ::CPU_ISET_65C02)
+
+; bit instructions for 65C02
+
+OPC_RMB0    = $07
+OPC_RMB1    = $17
+OPC_RMB2    = $27
+OPC_RMB3    = $37
+OPC_RMB4    = $47
+OPC_RMB5    = $57
+OPC_RMB6    = $67
+OPC_RMB7    = $77
+
+OPC_SMB0    = $87
+OPC_SMB1    = $97
+OPC_SMB2    = $A7
+OPC_SMB3    = $B7
+OPC_SMB4    = $C7
+OPC_SMB5    = $D7
+OPC_SMB6    = $E7
+OPC_SMB7    = $F7
+
+OPC_BBR0    = $0F
+OPC_BBR1    = $1F
+OPC_BBR2    = $2F
+OPC_BBR3    = $3F
+OPC_BBR4    = $4F
+OPC_BBR5    = $5F
+OPC_BBR6    = $6F
+OPC_BBR7    = $7F
+
+OPC_BBS0    = $8F
+OPC_BBS1    = $9F
+OPC_BBS2    = $AF
+OPC_BBS3    = $BF
+OPC_BBS4    = $CF
+OPC_BBS5    = $DF
+OPC_BBS6    = $EF
+OPC_BBS7    = $FF
+
+.else
+
+; no bit instructions for 65SC02
+
+; OPC_NOP   = $07               ; doublet
+; OPC_NOP   = $17               ; doublet
+; OPC_NOP   = $27               ; doublet
+; OPC_NOP   = $37               ; doublet
+; OPC_NOP   = $47               ; doublet
+; OPC_NOP   = $57               ; doublet
+; OPC_NOP   = $67               ; doublet
+; OPC_NOP   = $77               ; doublet
+; OPC_NOP   = $87               ; doublet
+; OPC_NOP   = $97               ; doublet
+; OPC_NOP   = $A7               ; doublet
+; OPC_NOP   = $B7               ; doublet
+; OPC_NOP   = $C7               ; doublet
+; OPC_NOP   = $D7               ; doublet
+; OPC_NOP   = $E7               ; doublet
+; OPC_NOP   = $F7               ; doublet
+; OPC_NOP   = $0F               ; doublet
+; OPC_NOP   = $1F               ; doublet
+; OPC_NOP   = $2F               ; doublet
+; OPC_NOP   = $3F               ; doublet
+; OPC_NOP   = $4F               ; doublet
+; OPC_NOP   = $5F               ; doublet
+; OPC_NOP   = $6F               ; doublet
+; OPC_NOP   = $7F               ; doublet
+; OPC_NOP   = $8F               ; doublet
+; OPC_NOP   = $9F               ; doublet
+; OPC_NOP   = $AF               ; doublet
+; OPC_NOP   = $BF               ; doublet
+; OPC_NOP   = $CF               ; doublet
+; OPC_NOP   = $DF               ; doublet
+; OPC_NOP   = $EF               ; doublet
+; OPC_NOP   = $FF               ; doublet
+
+.endif
+
+.elseif (.cpu .bitand ::CPU_ISET_6502X)
+
+; stable, undocumented opcodes
+
+; OPC_KIL   = $02               ; unstable
+OPC_SLO_izx = $03
+OPC_NOP_zp  = $04
+OPC_SLO_zp  = $07
+OPC_ANC_imm = $0B
+OPC_NOP_abs = $0C
+OPC_SLO_abs = $0F
+
+; OPC_KIL   = $12               ; unstable
+OPC_SLO_izy = $13
+OPC_NOP_zpx = $14
+OPC_SLO_zpx = $17
+;OPC_NOP    = $1A
+OPC_SLO_aby = $1B
+OPC_NOP_abx = $1C
+OPC_SLO_abx = $1F
+
+; OPC_KIL   = $22               ; unstable
+OPC_RLA_izx = $23
+OPC_RLA_zp  = $27
+OPC_ANC_imm = $2B
+OPC_RLA_abs = $2F
+
+; OPC_KIL   = $32               ; unstable
+OPC_RLA_izy = $33
+OPC_NOP_zpx = $34
+OPC_RLA_zpx = $37
+; OPC_NOP   = $3A               ; doublet
+OPC_RLA_aby = $3B
+OPC_NOP_abx = $3C
+OPC_RLA_abx = $3F
+
+; OPC_KIL   = $42               ; unstable
+OPC_SRE_izx = $43
+OPC_NOP_zp  = $44
+OPC_SRE_zp  = $47
+OPC_ALR_imm = $4B
+OPC_SRE_abs = $4F
+
+; OPC_KIL   = $52               ; unstable
+OPC_SRE_izy = $53
+OPC_NOP_zpx = $54
+OPC_SRE_zpx = $57
+; OPC_NOP   = $5A               ; doublet
+OPC_SRE_aby = $5B
+OPC_NOP_abx = $5C
+OPC_SRE_abx = $5F
+
+; OPC_KIL   = $62
+OPC_RRA_izx = $63
+OPC_NOP_zp  = $64
+OPC_RRA_zp  = $67
+OPC_ARR_imm = $6B
+OPC_RRA_abs = $6F
+
+; OPC_KIL   = $72
+OPC_RRA_izy = $73
+OPC_NOP_zpx = $74
+OPC_RRA_zpx = $77
+; OPC_NOP   = $7A               ; doublet
+OPC_RRA_aby = $7B
+OPC_NOP_abx = $7C
+OPC_RRA_abx = $7F
+
+OPC_NOP_imm = $80
+; OPC_NOP_imm = $82             ; doublet
+OPC_SAX_izx = $83
+OPC_SAX_zp  = $87
+; OPC_NOP_imm = $89             ; doublet
+; OPC_XAA = $8B                 ; unstable
+OPC_SAX_abs = $8F
+
+; OPC_KIL   = $92               ; unstable
+; OPC_AHX_izy = $93             ; unstable
+OPC_SAX_zpy = $97
+; OPC_TAS_aby = $9B             ; unstable
+; OPC_SHY_abx = $9C             ; unstable
+; OPC_SHX_aby = $9E             ; unstable
+; OPC_AHX_aby = $9F             ; unstable
+
+OPC_LAX_izx = $A3
+OPC_LAX_zp  = $A7
+; OPC_LAX_imm = $AB             ; unstable
+OPC_LAX_abs = $AF
+
+; OPC_KIL   = $B2               ; unstable
+OPC_LAX_izy = $B3
+OPC_LAX_zpy = $B7
+OPC_LAS_aby = $BB
+OPC_LAX_aby = $BF
+
+; OPC_NOP_imm = $C2             ; doublet
+OPC_DCP_izx = $C3
+OPC_DCP_zp  = $C7
+OPC_AXS_imm = $CB
+OPC_DCP_abs = $CF
+
+; OPC_KIL   = $D2               ; unstable
+OPC_DCP_izy = $D3
+OPC_NOP_zpx = $D4
+OPC_DCP_zpx = $D7
+OPC_NOP_DA  = $DA
+OPC_DCP_aby = $DB
+OPC_NOP_abx = $DC
+OPC_DCP_abx = $DF
+
+; OPC_NOP_imm = $E2             ; doublet
+OPC_ISC_izx = $E3
+OPC_ISC_zp  = $E7
+; OPC_SBC_imm = $EB             ; doublet
+OPC_ISC_abs = $EF
+
+; OPC_KIL   = $F2               ; unstable
+OPC_ISC_izy = $F3
+OPC_NOP_zpx = $F4
+OPC_ISC_zpx = $F7
+OPC_NOP_FA  = $FA
+OPC_ISC_aby = $FB
+OPC_NOP_abx = $FC
+OPC_ISC_abx = $FF
+
+.endif
index a745a89c8b1693a4b1a065c4790f710627c457d1..43d52a5d5c406f26fcaa7c19741a12643d6e96bd 100644 (file)
@@ -26,11 +26,22 @@ SCR_LINELEN     := $D5          ; Screen line length
 CURS_Y          := $D8          ; Cursor row
 FNADR           := $DA          ; Pointer to file name
 
+; 80-Column CBMs
+KBDREPEAT80     := $E4
+KBDRPTRATE80    := $E5
+KBDRPTDELAY80   := $E6
+
 BASIC_BUF       := $200         ; Location of command-line
 BASIC_BUF_LEN   = 81            ; Maximum length of command-line
 
 KEY_BUF         := $26F         ; Keyboard buffer
 
+; 40-Column PETs/CBMs
+KBDRPTDELAY40   := $3E9
+KBDRPTRATE40    := $3EA
+KBDREPEAT40     := $3EE
+KBDREPEAT40B    := $3F8
+
 ;----------------------------------------------------------------------------
 ; PET ROM type detection
 
@@ -55,5 +66,3 @@ VIA_PRB         := $E840
 VIA_PRA         := $E841
 VIA_DDRB        := $E842
 VIA_DDRA        := $E843
-
-
index 69b2298a37977467d55584eafd418a15cb7455df..3b2f08c54db306ac222ea890db31ff47e54f0e3f 100644 (file)
@@ -33,6 +33,10 @@ FKEY_COUNT      := $55D         ; Characters for function key
 FKEY_SPACE      := $55F         ; Function key definitions
 FKEY_ORIG       := $F3D2        ; Original definitions
 
+KBDREPEAT       := $540
+KBDREPEATRATE   := $541
+KBDREPEATDELAY  := $542
+
 ; ---------------------------------------------------------------------------
 ; Kernal routines
 
index d5752a5f5cb17ed1211d63b47ec85114005f93c7..0583f79e0ba97a3eea7e0e7b2cf9b033fedb1a70 100644 (file)
-; smc.mac\r
-; ca65 Macro-Pack for Self Modifying Code (SMC)\r
-;\r
-; (c) Christian Krüger, latest change: 17-Jul-2016\r
-;\r
-; This software is provided 'as-is', without any expressed or implied\r
-; warranty.  In no event will the authors be held liable for any damages\r
-; arising from the use of this software.\r
-;\r
-; Permission is granted to anyone to use this software for any purpose,\r
-; including commercial applications, and to alter it and redistribute it\r
-; freely, subject to the following restrictions:\r
-;\r
-; 1. The origin of this software must not be misrepresented; you must not\r
-;    claim that you wrote the original software. If you use this software\r
-;    in a product, an acknowledgment in the product documentation would be\r
-;    appreciated but is not required.\r
-; 2. Altered source versions must be plainly marked as such, and must not\r
-;    be misrepresented as being the original software.\r
-; 3. This notice may not be removed or altered from any source\r
-;    distribution.\r
-;\r
-\r
-.define _SMCDesignator  .mid(0, .tcount(label) - 1, label) .ident(.concat(.string(.right(1, label)), "_SMC"))\r
-.define _SMCAlias       .mid(0, .tcount(alias) - 1, alias) .ident(.concat(.string(.right(1, alias)), "_SMC"))\r
-.define SMC_AbsAdr      $FADE\r
-.define SMC_ZpAdr       $00\r
-.define SMC_Opcode      nop\r
-.define SMC_Value       $42\r
-\r
-.macro SMC_OperateOnValue opcode, label\r
-        opcode _SMCDesignator+1\r
-.endmacro\r
-\r
-.macro SMC_OperateOnLowByte opcode, label\r
-        SMC_OperateOnValue opcode, label\r
-.endmacro\r
-\r
-.macro SMC_OperateOnHighByte opcode, label\r
-        opcode _SMCDesignator + 2\r
-.endmacro\r
-\r
-.macro SMC_Import alias\r
-.import _SMCAlias\r
-.endmacro\r
-\r
-.macro SMC_Export alias, label\r
-.export _SMCAlias := _SMCDesignator\r
-.endmacro\r
-\r
-.macro  SMC     label, statement\r
-_SMCDesignator: statement\r
-.endmacro\r
-\r
-.macro SMC_TransferOpcode       label, opcode, register\r
-.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )\r
-        lda #opcode\r
-        sta _SMCDesignator\r
-.elseif .match ({register}, x)\r
-        ldx #opcode\r
-        stx _SMCDesignator\r
-.elseif .match ({register}, y)\r
-        ldy #opcode\r
-        sty _SMCDesignator\r
-.else\r
-       .error "Invalid usage of macro 'SMC_TransferOpcode'"\r
-.endif\r
-.endmacro\r
-\r
-.macro SMC_LoadOpcode   label, register\r
-.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )\r
-        lda _SMCDesignator\r
-.elseif .match ({register}, x)\r
-        ldx _SMCDesignator\r
-.elseif .match ({register}, y)\r
-        ldy _SMCDesignator\r
-.else\r
-       .error "Invalid usage of macro 'SMC_LoadOpcode'"\r
-.endif\r
-.endmacro\r
-\r
-.macro SMC_StoreOpcode  label, register\r
-.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )\r
-        sta _SMCDesignator\r
-.elseif .match ({register}, x)\r
-        stx _SMCDesignator\r
-.elseif .match ({register}, y)\r
-        sty _SMCDesignator\r
-.else\r
-       .error "Invalid usage of macro 'SMC_StoreOpcode'"\r
-.endif\r
-.endmacro\r
-\r
-.macro SMC_ChangeBranch         label, destination, register\r
-.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )\r
-        lda #(<(destination - _SMCDesignator -2))\r
-        sta _SMCDesignator+1\r
-.elseif .match ({register}, x)\r
-        ldx #(<(destination - _SMCDesignator - 2))\r
-        stx _SMCDesignator+1\r
-.elseif .match ({register}, y)\r
-        ldy #(<(destination - _SMCDesignator - 2))\r
-        sty _SMCDesignator+1\r
-.else\r
-       .error "Invalid usage of macro 'SMC_ChangeBranch'"\r
-.endif\r
-.endmacro\r
-\r
-.macro SMC_TransferValue        label, value, register\r
-.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )\r
-        lda value\r
-        sta _SMCDesignator+1\r
-.elseif .match ({register}, x)\r
-        ldx value\r
-        stx _SMCDesignator+1\r
-.elseif .match ({register}, y)\r
-        ldy value\r
-        sty _SMCDesignator+1\r
-.else\r
-       .error "Invalid usage of macro 'SMC_TransferValue'"\r
-.endif\r
-.endmacro\r
-\r
-.macro SMC_LoadValue    label, register\r
-.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )\r
-        lda _SMCDesignator+1\r
-.elseif .match ({register}, x)\r
-        ldx _SMCDesignator+1\r
-.elseif .match ({register}, y)\r
-        ldy _SMCDesignator+1\r
-.else\r
-       .error "Invalid usage of macro 'SMC_LoadValue'"\r
-.endif\r
-.endmacro\r
-\r
-.macro SMC_StoreValue   label, register\r
-.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )\r
-        sta _SMCDesignator+1\r
-.elseif .match ({register}, x)\r
-        stx _SMCDesignator+1\r
-.elseif .match ({register}, y)\r
-        sty _SMCDesignator+1\r
-.else\r
-       .error "Invalid usage of macro 'SMC_StoreValue'"\r
-.endif\r
-.endmacro\r
-\r
-\r
-.macro SMC_TransferLowByte      label, value, register\r
-SMC_TransferValue label, value, register\r
-.endmacro\r
-\r
-.macro SMC_LoadLowByte  label, register\r
-SMC_LoadValue label, register\r
-.endmacro\r
-\r
-.macro SMC_StoreLowByte label, register\r
-SMC_StoreValue label, register\r
-.endmacro\r
-\r
-.macro SMC_TransferHighByte     label, value, register\r
-.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )\r
-        lda value\r
-        sta _SMCDesignator+2\r
-.elseif .match ({register}, x)\r
-        ldx value\r
-        stx _SMCDesignator+2\r
-.elseif .match ({register}, y)\r
-        ldy value\r
-        sty _SMCDesignator+2\r
-.else\r
-       .error "Invalid usage of macro 'SMC_TransferHighByte'"\r
-.endif\r
-.endmacro\r
-\r
-.macro SMC_LoadHighByte label, register\r
-.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )\r
-        lda _SMCDesignator+2\r
-.elseif .match ({register}, x)\r
-        ldx _SMCDesignator+2\r
-.elseif .match ({register}, y)\r
-        ldy _SMCDesignator+2\r
-.else\r
-       .error "Invalid usage of macro 'SMC_LoadHighByte'"\r
-.endif\r
-.endmacro\r
-\r
-.macro SMC_StoreHighByte        label, register\r
-.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )\r
-        sta _SMCDesignator+2\r
-.elseif .match ({register}, x)\r
-        stx _SMCDesignator+2\r
-.elseif .match ({register}, y)\r
-        sty _SMCDesignator+2\r
-.else\r
-       .error "Invalid usage of macro 'SMC_StoreHighByte'"\r
-.endif\r
-.endmacro\r
-\r
-.macro SMC_TransferAddressSingle        label, address, register\r
-.if .paramcount = 2 .or .match ((register), a) .or .match ({register}, )\r
-        .if (.match (.left (1, {address}), #))\r
-                ; immediate mode\r
-                lda #<(.right (.tcount ({address})-1, {address}))\r
-                sta _SMCDesignator+1\r
-                lda #>(.right (.tcount ({address})-1, {address}))\r
-                sta _SMCDesignator+2\r
-        .else\r
-                ; assume absolute or zero page\r
-                lda address\r
-                sta _SMCDesignator+1\r
-                lda 1+(address)\r
-                sta _SMCDesignator+2\r
-        .endif\r
-.elseif .match ((register), x)\r
-        .if (.match (.left (1, {address}), #))\r
-                ; immediate mode\r
-                ldx #<(.right (.tcount ({address})-1, {address}))\r
-                stx _SMCDesignator+1\r
-                ldx #>(.right (.tcount ({address})-1, {address}))\r
-                stx _SMCDesignator+2\r
-        .else\r
-                ; assume absolute or zero page\r
-                ldx address\r
-                stx _SMCDesignator+1\r
-                ldx 1+(address)\r
-                stx _SMCDesignator+2\r
-        .endif\r
-.elseif .match ((register), y)\r
-        .if (.match (.left (1, {address}), #))\r
-                ; immediate mode\r
-                ldy #<(.right (.tcount ({address})-1, {address}))\r
-                sty _SMCDesignator+1\r
-                ldy #>(.right (.tcount ({address})-1, {address}))\r
-                sty _SMCDesignator+2\r
-        .else\r
-                ; assume absolute or zero page\r
-                ldy address\r
-                sty _SMCDesignator+1\r
-                ldy 1+(address)\r
-                sty _SMCDesignator+2\r
-        .endif\r
-.else\r
-       .error "Invalid usage of macro 'SMC_TransferAddressSingle'"\r
-.endif\r
-.endmacro\r
-\r
-.macro SMC_TransferAddress      label, address\r
-.if (.match (.left (1, {address}), #))\r
-        ; immediate mode\r
-        lda #<(.right (.tcount ({address})-1, {address}))\r
-        sta _SMCDesignator+1\r
-        ldx #>(.right (.tcount ({address})-1, {address}))\r
-        stx _SMCDesignator+2\r
-.else\r
-        ; assume absolute or zero page\r
-        lda {address}\r
-        sta _SMCDesignator+1\r
-        ldx 1+{address}\r
-        stx _SMCDesignator)+2\r
-.endif\r
-.endmacro\r
-\r
-.macro SMC_StoreAddress label\r
-        sta _SMCDesignator+1\r
-        stx _SMCDesignator+2\r
-.endmacro\r
+; smc.mac
+; ca65 Macro-Pack for Self Modifying Code (SMC)
+;
+; (c) Christian Krüger, latest change: 17-Jul-2016
+;
+; This software is provided 'as-is', without any expressed or implied
+; warranty.  In no event will the authors be held liable for any damages
+; arising from the use of this software.
+;
+; Permission is granted to anyone to use this software for any purpose,
+; including commercial applications, and to alter it and redistribute it
+; freely, subject to the following restrictions:
+;
+; 1. The origin of this software must not be misrepresented; you must not
+;    claim that you wrote the original software. If you use this software
+;    in a product, an acknowledgment in the product documentation would be
+;    appreciated but is not required.
+; 2. Altered source versions must be plainly marked as such, and must not
+;    be misrepresented as being the original software.
+; 3. This notice may not be removed or altered from any source
+;    distribution.
+;
+
+.define _SMCDesignator  .mid(0, .tcount(label) - 1, label) .ident(.concat(.string(.right(1, label)), "_SMC"))
+.define _SMCAlias       .mid(0, .tcount(alias) - 1, alias) .ident(.concat(.string(.right(1, alias)), "_SMC"))
+.define SMC_AbsAdr      $FADE
+.define SMC_ZpAdr       $00
+.define SMC_Opcode      nop
+.define SMC_Value       $42
+
+.macro SMC_OperateOnValue opcode, label
+        opcode _SMCDesignator+1
+.endmacro
+
+.macro SMC_OperateOnLowByte opcode, label
+        SMC_OperateOnValue opcode, label
+.endmacro
+
+.macro SMC_OperateOnHighByte opcode, label
+        opcode _SMCDesignator + 2
+.endmacro
+
+.macro SMC_Import alias
+.import _SMCAlias
+.endmacro
+
+.macro SMC_Export alias, label
+.export _SMCAlias := _SMCDesignator
+.endmacro
+
+.macro  SMC     label, statement
+_SMCDesignator: statement
+.endmacro
+
+.macro SMC_TransferOpcode       label, opcode, register
+.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )
+        lda #opcode
+        sta _SMCDesignator
+.elseif .match ({register}, x)
+        ldx #opcode
+        stx _SMCDesignator
+.elseif .match ({register}, y)
+        ldy #opcode
+        sty _SMCDesignator
+.else
+       .error "Invalid usage of macro 'SMC_TransferOpcode'"
+.endif
+.endmacro
+
+.macro SMC_LoadOpcode   label, register
+.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
+        lda _SMCDesignator
+.elseif .match ({register}, x)
+        ldx _SMCDesignator
+.elseif .match ({register}, y)
+        ldy _SMCDesignator
+.else
+       .error "Invalid usage of macro 'SMC_LoadOpcode'"
+.endif
+.endmacro
+
+.macro SMC_StoreOpcode  label, register
+.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
+        sta _SMCDesignator
+.elseif .match ({register}, x)
+        stx _SMCDesignator
+.elseif .match ({register}, y)
+        sty _SMCDesignator
+.else
+       .error "Invalid usage of macro 'SMC_StoreOpcode'"
+.endif
+.endmacro
+
+.macro SMC_ChangeBranch         label, destination, register
+.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )
+        lda #(<(destination - _SMCDesignator -2))
+        sta _SMCDesignator+1
+.elseif .match ({register}, x)
+        ldx #(<(destination - _SMCDesignator - 2))
+        stx _SMCDesignator+1
+.elseif .match ({register}, y)
+        ldy #(<(destination - _SMCDesignator - 2))
+        sty _SMCDesignator+1
+.else
+       .error "Invalid usage of macro 'SMC_ChangeBranch'"
+.endif
+.endmacro
+
+.macro SMC_TransferValue        label, value, register
+.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )
+        lda value
+        sta _SMCDesignator+1
+.elseif .match ({register}, x)
+        ldx value
+        stx _SMCDesignator+1
+.elseif .match ({register}, y)
+        ldy value
+        sty _SMCDesignator+1
+.else
+       .error "Invalid usage of macro 'SMC_TransferValue'"
+.endif
+.endmacro
+
+.macro SMC_LoadValue    label, register
+.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
+        lda _SMCDesignator+1
+.elseif .match ({register}, x)
+        ldx _SMCDesignator+1
+.elseif .match ({register}, y)
+        ldy _SMCDesignator+1
+.else
+       .error "Invalid usage of macro 'SMC_LoadValue'"
+.endif
+.endmacro
+
+.macro SMC_StoreValue   label, register
+.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
+        sta _SMCDesignator+1
+.elseif .match ({register}, x)
+        stx _SMCDesignator+1
+.elseif .match ({register}, y)
+        sty _SMCDesignator+1
+.else
+       .error "Invalid usage of macro 'SMC_StoreValue'"
+.endif
+.endmacro
+
+
+.macro SMC_TransferLowByte      label, value, register
+SMC_TransferValue label, value, register
+.endmacro
+
+.macro SMC_LoadLowByte  label, register
+SMC_LoadValue label, register
+.endmacro
+
+.macro SMC_StoreLowByte label, register
+SMC_StoreValue label, register
+.endmacro
+
+.macro SMC_TransferHighByte     label, value, register
+.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )
+        lda value
+        sta _SMCDesignator+2
+.elseif .match ({register}, x)
+        ldx value
+        stx _SMCDesignator+2
+.elseif .match ({register}, y)
+        ldy value
+        sty _SMCDesignator+2
+.else
+       .error "Invalid usage of macro 'SMC_TransferHighByte'"
+.endif
+.endmacro
+
+.macro SMC_LoadHighByte label, register
+.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
+        lda _SMCDesignator+2
+.elseif .match ({register}, x)
+        ldx _SMCDesignator+2
+.elseif .match ({register}, y)
+        ldy _SMCDesignator+2
+.else
+       .error "Invalid usage of macro 'SMC_LoadHighByte'"
+.endif
+.endmacro
+
+.macro SMC_StoreHighByte        label, register
+.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
+        sta _SMCDesignator+2
+.elseif .match ({register}, x)
+        stx _SMCDesignator+2
+.elseif .match ({register}, y)
+        sty _SMCDesignator+2
+.else
+       .error "Invalid usage of macro 'SMC_StoreHighByte'"
+.endif
+.endmacro
+
+.macro SMC_TransferAddressSingle        label, address, register
+.if .paramcount = 2 .or .match ((register), a) .or .match ({register}, )
+        .if (.match (.left (1, {address}), #))
+                ; immediate mode
+                lda #<(.right (.tcount ({address})-1, {address}))
+                sta _SMCDesignator+1
+                lda #>(.right (.tcount ({address})-1, {address}))
+                sta _SMCDesignator+2
+        .else
+                ; assume absolute or zero page
+                lda address
+                sta _SMCDesignator+1
+                lda 1+(address)
+                sta _SMCDesignator+2
+        .endif
+.elseif .match ((register), x)
+        .if (.match (.left (1, {address}), #))
+                ; immediate mode
+                ldx #<(.right (.tcount ({address})-1, {address}))
+                stx _SMCDesignator+1
+                ldx #>(.right (.tcount ({address})-1, {address}))
+                stx _SMCDesignator+2
+        .else
+                ; assume absolute or zero page
+                ldx address
+                stx _SMCDesignator+1
+                ldx 1+(address)
+                stx _SMCDesignator+2
+        .endif
+.elseif .match ((register), y)
+        .if (.match (.left (1, {address}), #))
+                ; immediate mode
+                ldy #<(.right (.tcount ({address})-1, {address}))
+                sty _SMCDesignator+1
+                ldy #>(.right (.tcount ({address})-1, {address}))
+                sty _SMCDesignator+2
+        .else
+                ; assume absolute or zero page
+                ldy address
+                sty _SMCDesignator+1
+                ldy 1+(address)
+                sty _SMCDesignator+2
+        .endif
+.else
+       .error "Invalid usage of macro 'SMC_TransferAddressSingle'"
+.endif
+.endmacro
+
+.macro SMC_TransferAddress      label, address
+.if (.match (.left (1, {address}), #))
+        ; immediate mode
+        lda #<(.right (.tcount ({address})-1, {address}))
+        sta _SMCDesignator+1
+        ldx #>(.right (.tcount ({address})-1, {address}))
+        stx _SMCDesignator+2
+.else
+        ; assume absolute or zero page
+        lda {address}
+        sta _SMCDesignator+1
+        ldx 1+{address}
+        stx _SMCDesignator)+2
+.endif
+.endmacro
+
+.macro SMC_StoreAddress label
+        sta _SMCDesignator+1
+        stx _SMCDesignator+2
+.endmacro
index 12424dc116626bc2267db0a812463430b068a927..d882eb1ad3a61b43fbf4adf2630794a9da6433a1 100644 (file)
@@ -31,6 +31,9 @@ BASIC_BUF_LEN   = 89            ; Maximum length of command-line
 CHARCOLOR       := $286
 CURS_COLOR      := $287         ; Color under the cursor
 
+KBDREPEAT       := $28a
+KBDREPEATRATE   := $28b
+KBDREPEATDELAY  := $28c
 
 ; ---------------------------------------------------------------------------
 ; Screen size
index 06e39b36ffdcb73a8612838b6dde52571ecb740f..9e4ecd8cea7bd2d294bf2dd65fb07f7d3e816955 100644 (file)
@@ -4,7 +4,7 @@ SYMBOLS {
 MEMORY {
     ZP:  file = "", define = yes, start = $0020, size = $00E0;
     RAM: file = "", define = yes, start = $01FA, size = $0206;
-    ROM: file = %O, define = yes, start = $B000, size = $1000;
+    ROM: file = %O, define = yes, start = $B000, size = $1000, fill = yes, fillval = $FF;
 }
 SEGMENTS {
     ZEROPAGE: load = ZP,             type = zp;
index b4f7738f5866ad8ad0432c90b932e55e496ac219..530787489f6679580f409a6306e1771f1fb70a3f 100644 (file)
@@ -3,7 +3,7 @@ SYMBOLS {
     __STACKSIZE__: type = weak, value = $0800; # 2k stack
 }
 MEMORY {
-    ZP:     file = "",               start = $0000, size = $001A;
+    ZP:     file = "",               start = $0000, size = $001B;
     HEADER: file = %O,               start = $0000, size = $0001;
     MAIN:   file = %O, define = yes, start = $0200, size = $FDF0 - __STACKSIZE__;
 }
index b4f7738f5866ad8ad0432c90b932e55e496ac219..530787489f6679580f409a6306e1771f1fb70a3f 100644 (file)
@@ -3,7 +3,7 @@ SYMBOLS {
     __STACKSIZE__: type = weak, value = $0800; # 2k stack
 }
 MEMORY {
-    ZP:     file = "",               start = $0000, size = $001A;
+    ZP:     file = "",               start = $0000, size = $001B;
     HEADER: file = %O,               start = $0000, size = $0001;
     MAIN:   file = %O, define = yes, start = $0200, size = $FDF0 - __STACKSIZE__;
 }
index 96a3ba59be457c8cc1ee606b7ee1d1ad1bc3b874..33b5c26865ac2476ca2c8ff339192a309f53caa0 100644 (file)
@@ -6,8 +6,8 @@ endif
 
 .SUFFIXES:
 
-htmldir = $(prefix)/share/doc/cc65$(DESTPACKAGE_SUFFIX)/html
-infodir = $(prefix)/share/info
+htmldir = $(PREFIX)/share/doc/cc65$(DESTPACKAGE_SUFFIX)/html
+infodir = $(PREFIX)/share/info
 
 ifdef CMD_EXE
 
@@ -46,7 +46,7 @@ clean:
        $(RM) -r ../html ../info
 
 install:
-       $(if $(prefix),,$(error variable `prefix' must be set))
+       $(if $(PREFIX),,$(error variable `PREFIX' must be set))
 ifeq ($(wildcard ../html),../html)
        $(INSTALL) -d $(DESTDIR)$(htmldir)
        $(INSTALL) -m0644 ../html/*.* $(DESTDIR)$(htmldir)
index d0405b6de6c3f3715a1256e37062e1941e1a8f8d..33a878223059af8c1d42a96d4a63fa427e4b3135 100644 (file)
@@ -435,7 +435,7 @@ BASIC.SYSTEM) there are some limitations for DOS 3.3:
   <tag/Interrupts/
   There's no <tt/interruptor/ support. Any attempt to use it yields the message
   'FAILED TO ALLOC INTERRUPT' on program startup. This implicitly means that
-  <tt/a2.stdmou.mou/ and <tt/a2.ssc.ser/ are not functional as they depend on
+  joystick, mouse and RS232 device drivers are not functional as they depend on
   interrupts.
 
 </descrip><p>
@@ -511,6 +511,109 @@ url="ca65.html" name="assembler manual">.
 </descrip><p>
 
 
+<sect1>Specifying file types for fopen<p>
+
+<descrip>
+
+  <tag>Explanation of File Types</tag>
+
+  ProDOS associates a file type and an auxiliary type with each file.
+  These type specifications are separate from the file's name, unlike
+  Windows which uses the file name's suffix (a.k.a.
+  extension) to specify the file type. For example, <tt/.exe/, 
+  <tt/.doc/, or <tt/.bat/.
+  The ProDOS low-level 
+  Machine-Language Interface (MLI) functions for creating and opening 
+  files require these types to be specified. And if they don't match
+  with the file being opened, the operation may fail.
+
+  In contrast, the ISO C function <tt/fopen()/ and the POSIX function
+  <tt/open()/ have no parameter to specify either a file type or an
+  auxiliary type. Therefore, some additional mechanism for specifying
+  the file types is needed. 
+  
+  <tag>Specifying the File Type and Auxiliary Type</tag>
+
+  There are two global variables provided that allow the file type
+  and auxiliary type to be specified before a call to <tt/fopen()/
+  or <tt/open()/. They are defined in <tt/apple2_filetype.h/:
+
+  <tscreen>
+  <verb>
+  extern unsigned char _filetype;  /* Default: PRODOS_T_BIN */
+  extern unsigned int _auxtype;    /* Default: 0            */
+  </verb>
+  </tscreen>  
+
+  The header file <tt/apple2_filetype.h/ also defines many values
+  that can be used to set these variables. It is included in
+  <tt/apple2.h/, which is in turn included in <tt/apple2enh.h/.
+  So it isn't necessary to include it directly. Just
+  include one of <tt/apple2.h/ or <tt/apple2enh.h/.
+
+  <tag>Example</tag>
+
+  A text file cannot be created with just the
+  standard C functions because they default to the binary type 
+  <tt/PRODOS_T_BIN/. The <tt/_filetype/ variable must be set to
+  <tt/PRODOS_T_TXT/ to create a text file. 
+  
+  For a text file, 
+  <tt/_auxtype/ specifies the record length. A zero record
+  length text file is referred to as a sequential text file.
+  This is equivalent to text files on 
+  other operating systems, except that the line terminator is a
+  carriage return instead of a line-feed (Linux/BSD/MacOS) or 
+  carriage return, line-feed pair (Windows).
+  
+  The "sequential" text file terminology is in contrast to a 
+  "random-access" text file which would
+  have a fixed-length, non-zero record length, so that the 
+  file position of any individual record can be calculated.
+  
+  For this example, the
+  <tt/_auxtype/ does not need to be set because it defaults to
+  the desired value, which is zero. To be more explicit, 
+  <tt/_auxtype/ can also be set to <tt/PRODOS_AUX_T_TXT_SEQ/
+  which is defined as zero.
+
+  <tscreen>
+  <verb>
+    &num;include &lt;stdio.h&gt;
+    &num;include &lt;string.h&gt;
+    &num;include &lt;errno.h&gt;
+    &num;include &lt;apple2.h&gt;
+
+    void main(void)
+    {
+        FILE *out;
+        char *name = "MY.FAVS";
+
+        /*-----------------------------*/
+
+        _filetype = PRODOS_T_TXT;
+        _auxtype  = PRODOS_AUX_T_TXT_SEQ;
+
+        /*-----------------------------*/
+
+        if ((out = fopen(name, "w")) != NULL) {
+            fputs("Jorah Mormont\r", out);
+            fputs("Brienne of Tarth\r", out);
+            fputs("Daenerys Targaryen\r", out);
+            fputs("Sandor Clegane\r", out);
+            if (fclose(out) == EOF) {
+                fprintf(stderr, "fclose failed for %s: %s", name, strerror(errno));
+            }
+        }
+        else {
+            fprintf(stderr, "fopen failed for %s: %s", name, strerror(errno));
+        }
+    }
+  </verb>
+  </tscreen>  
+
+</descrip><p>
+
 
 <sect>License<p>
 
index b5231b4cd2e803d1ceff40f1dab47fa5225e520b..4f520254386a1f3b20440368a2a7e61d157536d6 100644 (file)
@@ -436,7 +436,7 @@ BASIC.SYSTEM) there are some limitations for DOS 3.3:
   <tag/Interrupts/
   There's no <tt/interruptor/ support. Any attempt to use it yields the message
   'Failed to alloc interrupt' on program startup. This implicitly means that
-  <tt/a2e.stdmou.mou/ and <tt/a2e.ssc.ser/ are not functional as they depend on
+  joystick, mouse and RS232 device drivers are not functional as they depend on
   interrupts.
 
 </descrip><p>
@@ -517,6 +517,109 @@ url="ca65.html" name="assembler manual">.
 </descrip><p>
 
 
+<sect1>Specifying file types for fopen<p>
+
+<descrip>
+
+  <tag>Explanation of File Types</tag>
+
+  ProDOS associates a file type and an auxiliary type with each file.
+  These type specifications are separate from the file's name, unlike
+  Windows which uses the file name's suffix (a.k.a.
+  extension) to specify the file type. For example, <tt/.exe/, 
+  <tt/.doc/, or <tt/.bat/.
+  The ProDOS low-level 
+  Machine-Language Interface (MLI) functions for creating and opening 
+  files require these types to be specified. And if they don't match
+  with the file being opened, the operation may fail.
+
+  In contrast, the ISO C function <tt/fopen()/ and the POSIX function
+  <tt/open()/ have no parameter to specify either a file type or an
+  auxiliary type. Therefore, some additional mechanism for specifying
+  the file types is needed. 
+  
+  <tag>Specifying the File Type and Auxiliary Type</tag>
+
+  There are two global variables provided that allow the file type
+  and auxiliary type to be specified before a call to <tt/fopen()/
+  or <tt/open()/. They are defined in <tt/apple2_filetype.h/:
+
+  <tscreen>
+  <verb>
+  extern unsigned char _filetype;  /* Default: PRODOS_T_BIN */
+  extern unsigned int _auxtype;    /* Default: 0            */
+  </verb>
+  </tscreen>  
+
+  The header file <tt/apple2_filetype.h/ also defines many values
+  that can be used to set these variables. It is included in
+  <tt/apple2.h/, which is in turn included in <tt/apple2enh.h/.
+  So it isn't necessary to include it directly. Just
+  include one of <tt/apple2.h/ or <tt/apple2enh.h/.
+
+  <tag>Example</tag>
+
+  A text file cannot be created with just the
+  standard C functions because they default to the binary type 
+  <tt/PRODOS_T_BIN/. The <tt/_filetype/ variable must be set to
+  <tt/PRODOS_T_TXT/ to create a text file. 
+  
+  For a text file, 
+  <tt/_auxtype/ specifies the record length. A zero record
+  length text file is referred to as a sequential text file.
+  This is equivalent to text files on 
+  other operating systems, except that the line terminator is a
+  carriage return instead of a line-feed (Linux/BSD/MacOS) or 
+  carriage return, line-feed pair (Windows).
+  
+  The "sequential" text file terminology is in contrast to a 
+  "random-access" text file which would
+  have a fixed-length, non-zero record length, so that the 
+  file position of any individual record can be calculated.
+  
+  For this example, the
+  <tt/_auxtype/ does not need to be set because it defaults to
+  the desired value, which is zero. To be more explicit, 
+  <tt/_auxtype/ can also be set to <tt/PRODOS_AUX_T_TXT_SEQ/
+  which is defined as zero.
+
+  <tscreen>
+  <verb>
+    &num;include &lt;stdio.h&gt;
+    &num;include &lt;string.h&gt;
+    &num;include &lt;errno.h&gt;
+    &num;include &lt;apple2.h&gt;
+
+    void main(void)
+    {
+        FILE *out;
+        char *name = "MY.FAVS";
+
+        /*-----------------------------*/
+
+        _filetype = PRODOS_T_TXT;
+        _auxtype  = PRODOS_AUX_T_TXT_SEQ;
+
+        /*-----------------------------*/
+
+        if ((out = fopen(name, "w")) != NULL) {
+            fputs("Jorah Mormont\r", out);
+            fputs("Brienne of Tarth\r", out);
+            fputs("Daenerys Targaryen\r", out);
+            fputs("Sandor Clegane\r", out);
+            if (fclose(out) == EOF) {
+                fprintf(stderr, "fclose failed for %s: %s", name, strerror(errno));
+            }
+        }
+        else {
+            fprintf(stderr, "fopen failed for %s: %s", name, strerror(errno));
+        }
+    }
+  </verb>
+  </tscreen>  
+
+</descrip><p>
+
 
 <sect>License<p>
 
index 136defd406cd610dc0b5e138cb35ac974d2c8beb..2e01025cac05d985ea9d16c248bbe0f0137d3be2 100644 (file)
@@ -4,7 +4,7 @@
 
 <title>ar65 Users Guide
 <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">
-<date>19.07.2000
+<date>2017-05-28
 
 <abstract>
 ar65 is an archiver for object files generated by ca65. It allows to create
@@ -32,16 +32,17 @@ for the cc65 compiler. ar65 is part of this suite.
 The archiver is called as follows:
 
 <tscreen><verb>
-       Usage: ar65 <operation> lib file|module ...
-       Operation is one of:
-               a       Add modules
-               d       Delete modules
-               l       List library contents
-               x       Extract modules
-                       V       Print the archiver version
+       Usage: ar65 <operation ...> lib file|module ...
+       Operations are some of:
+               r       Add modules
+               d       Delete modules
+               t       List library table
+               v       Increase verbosity (put before other operation)
+               x       Extract modules
+               V       Print the archiver version
 </verb></tscreen>
 
-You may add modules to a library using the `a' command. If the library
+You may add modules to a library using the `r' command (`a' is deprecated). If the library
 does not exist, it is created (and a warning message is printed which you
 may ignore if creation of the library was your intention). You may
 specify any number of modules on the command line following the library.
@@ -53,7 +54,7 @@ has a newer timestamp than the one to add.
 Here's an example:
 
 <tscreen><verb>
-       ar65 a mysubs.lib sub1.o sub2.o
+       ar65 r mysubs.lib sub1.o sub2.o
 </verb></tscreen>
 
 This will add two modules to the library `mysubs.lib' creating the
@@ -63,10 +64,10 @@ sub2.o, they are replaced by the new ones.
 Modules names in the library are stored without the path, so, using
 
 <tscreen><verb>
-       ar65 a mysubs.lib ofiles/sub1.o ofiles/sub2.o
+       ar65 v v r mysubs.lib ofiles/sub1.o ofiles/sub2.o
 </verb></tscreen>
 
-will add two modules named `sub1.o' and `sub2.o' to the library.
+will verbose add two modules named `sub1.o' and `sub2.o' to the library.
 
 Deleting modules from a library is done with the `d' command. You may not
 give a path when naming the modules.
@@ -81,13 +82,13 @@ This will delete the module named `sub1.o' from the library, printing an
 error if the library does not contain that module.
 
 
-The `l' command prints a list of all modules in the library. Any module
-names on the command line are ignored.
+The `t' command prints a table of all modules in the library (`l' is deprecated).
+Any module names on the command line are ignored.
 
 Example:
 
 <tscreen><verb>
-       ar65 l mysubs.lib
+       ar65 tv mysubs.lib
 </verb></tscreen>
 
 
index da0233c62a6c67539e97fbba08298e02bb2ac35e..715ecd89ec968bc472401de79a2ab1c3f5a840d0 100644 (file)
@@ -1636,7 +1636,7 @@ either a string or an expression.
 
   <tscreen><verb>
         ; Reserve space for the larger of two data blocks
-               savearea:       .max (.sizeof (foo), .sizeof (bar))
+               savearea:       .res .max (.sizeof (foo), .sizeof (bar))
   </verb></tscreen>
 
   See: <tt><ref id=".MIN" name=".MIN"></tt>
@@ -1695,8 +1695,8 @@ either a string or an expression.
   Example:
 
   <tscreen><verb>
-        ; Reserve space for some data, but 256 bytes minimum
-               savearea:       .min (.sizeof (foo), 256)
+        ; Reserve space for some data, but 256 bytes maximum
+               savearea:       .res .min (.sizeof (foo), 256)
   </verb></tscreen>
 
   See: <tt><ref id=".MAX" name=".MAX"></tt>
@@ -4305,6 +4305,13 @@ different:
        some things may be done with both macro types, each type has special
        usages. The types complement each other.
 
+<item> Parentheses work differently from C macros.
+       The common practice of wrapping C macros in parentheses may cause
+       unintended problems here, such as accidentally implying an
+       indirect addressing mode. While the definition of a macro requires
+       parentheses around its argument list, when invoked they should not be
+       included.
+
 </itemize>
 
 Let's look at a few examples to make the advantages and disadvantages
@@ -4337,18 +4344,42 @@ Macros with parameters may also be useful:
         DEBUG   "Assembling include file #3"
 </verb></tscreen>
 
-Note that, while formal parameters have to be placed in braces, this is
-not true for the actual parameters. Beware: Since the assembler cannot
-detect the end of one parameter, only the first token is used. If you
-don't like that, use classic macros instead:
+Note that, while formal parameters have to be placed in parentheses,
+the actual argument used when invoking the macro should not be.
+The invoked arguments are separated by commas only, if parentheses are
+used by accident they will become part of the replaced token.
+
+If you wish to have an expression follow the macro invocation, the
+last parameter can be enclosed in curly braces {} to indicate the end of that
+argument.
+
+Examples:
 
 <tscreen><verb>
-.macro  DEBUG   message
-        .out    message
-.endmacro
+.define COMBINE(ta,tb,tc) ta+tb*10+tc*100
+
+.word COMBINE 5,6,7      ; 5+6*10+7*100 = 765
+.word COMBINE(5,6,7)     ; (5+6*10+7)*100 = 7200 ; incorrect use of parentheses
+.word COMBINE 5,6,7+1    ; 5+6*10+7+1*100 = 172
+.word COMBINE 5,6,{7}+1  ; 5+6*10+7*100+1 = 766 ; {} encloses the argument
+.word COMBINE 5,6-2,7    ; 5+6-2*10+7*100 = 691
+.word COMBINE 5,(6-2),7  ; 5+(6-2)*10+7*100 = 745
+.word COMBINE 5,6,7+COMBINE 0,1,2    ; 5+6*10+7+0+1*10+2*100*100 = 20082
+.word COMBINE 5,6,{7}+COMBINE 0,1,2  ; 5+6*10+7*100+0+1*10+2*100 = 975
 </verb></tscreen>
 
-(That is an example where a problem can be solved with both macro types).
+With C macros it is common to enclose the results in parentheses to
+prevent unintended interactions with the text of the arguments, but
+additional care must be taken in this assembly context where parentheses
+may alter the meaning of a statement. In particular, indirect addressing modes
+may be accidentally implied:
+
+<tscreen><verb>
+.define DUO(ta,tb) (ta+(tb*10))
+
+        lda DUO(5,4), Y         ; LDA (indirect), Y
+        lda 0+DUO(5,4), Y       ; LDA absolute indexed, Y
+</verb></tscreen>
 
 
 <sect1>Characters in macros<p>
index c24eba142da8c1170752638465f69a7c4c60bbd8..b171c2ce399d8ecf0a55ed6819e6339d44eca80f 100644 (file)
@@ -67,7 +67,7 @@ Special locations:
 
 <descrip>
   <tag/Stack/
-  The C runtime stack is located at &dollar;FF81, and grows downwards.
+  The C runtime stack is located at &dollar;FEC2, and grows downwards.
 
   <tag/Heap/
   The C heap is located at the end of the program, and grows towards the C
index 80dba89b8b492e1ca85675a1f67b0c91fcf803ca..cd94f50acd8d16c3b080033718f99d13dc856fa4 100644 (file)
@@ -4,7 +4,7 @@
 <title>cc65 Users Guide
 <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline>
 <url url="mailto:gregdk@users.sf.net" name="Greg King">
-<date>2016-06-11
+<date>2017-05-20
 
 <abstract>
 cc65 is a C compiler for 6502 targets. It supports several 6502 based home
@@ -58,7 +58,7 @@ Short options:
   -O                            Optimize code
   -Oi                           Optimize code, inline more code
   -Or                           Enable register variables
-  -Os                           Inline some known functions
+  -Os                           Inline some standard functions
   -T                            Include source as comment
   -V                            Print the compiler version number
   -W warning[,...]              Suppress warnings
@@ -88,9 +88,11 @@ Long options:
   --debug-opt name              Debug optimization steps
   --dep-target target           Use this dependency target
   --disable-opt name            Disable an optimization step
+  --eagerly-inline-funcs        Eagerly inline some known functions
   --enable-opt name             Enable an optimization step
   --help                        Help (this text)
   --include-dir dir             Set an include directory search path
+  --inline-stdfuncs             Inline some standard functions
   --list-opt-steps              List all optimizer steps and exit
   --list-warnings               List available warning types for -W
   --local-strings               Emit string literals immediately
@@ -219,11 +221,53 @@ Here is a description of all the command line options:
   symbols in a special section in the object file.
 
 
+  <label id="option-eagerly-inline-funcs">
+  <tag><tt>--eagerly-inline-funcs</tt></tag>
+
+  Have the compiler eagerly inline these functions from the C library:
+  <itemize>
+  <item><tt/memcpy()/
+  <item><tt/memset()/
+  <item><tt/strcmp()/
+  <item><tt/strcpy()/
+  <item><tt/strlen()/
+  <item>most of the functions declared in <tt/&lt;ctype.h&gt;/
+  </itemize>
+
+  Note: This has two consequences:
+  <itemize>
+  <item>You may not use names of standard C functions for your own functions.
+        If you do that, your program is not standard-compliant anyway; but,
+        using <tt/--eagerly-inline-funcs/ actually will break things.
+        <p>
+  <item>The inlined string and memory functions will not handle strings or
+        memory areas larger than 255 bytes.  Similarly, the inlined <tt/is..()/
+        functions will not work with values outside the char. range (such as
+        <tt/EOF/).
+        <p>
+  </itemize>
+
+  <tt/--eagerly-inline-funcs/ implies the <tt><ref id="option-inline-stdfuncs"
+  name="--inline-stdfuncs"></tt> command line option.
+
+  See also <tt><ref id="pragma-allow-eager-inline" name="#pragma&nbsp;allow-eager-inline"></tt>.
+
+
   <tag><tt>-h, --help</tt></tag>
 
   Print the short option summary shown above.
 
 
+  <label id="option-inline-stdfuncs">
+  <tag><tt>--inline-stdfuncs</tt></tag>
+
+  Allow the compiler to inline some standard functions from the C library like
+  strlen.  This will not only remove the overhead for a function call, but will
+  make the code visible for the optimizer.  See also the <tt><ref id="option-O"
+  name="-Os"></tt> command line option and <tt><ref id="pragma-inline-stdfuncs"
+  name="#pragma&nbsp;inline-stdfuncs"></tt>.
+
+
   <label id="option-list-warnings">
   <tag><tt>--list-warnings</tt></tag>
 
@@ -392,22 +436,22 @@ Here is a description of all the command line options:
   using
 
   <tscreen><verb>
-       void f (void)
-       {
-           unsigned a = 1;
-           ...
-       }
+        void f (void)
+        {
+            unsigned a = 1;
+            ...
+        }
   </verb></tscreen>
 
   the variable <tt/a/ will always have the value <tt/1/ when entering the
   function and using <tt/-Cl/, while in
 
   <tscreen><verb>
-       void f (void)
-       {
-           static unsigned a = 1;
-           ....
-       }
+        void f (void)
+        {
+            static unsigned a = 1;
+            ....
+        }
   </verb></tscreen>
 
   the variable <tt/a/ will have the value <tt/1/ only the first time that the
@@ -444,23 +488,14 @@ Here is a description of all the command line options:
   name="--register-vars">/ command line option, and the <ref
   id="register-vars" name="discussion of register variables"> below.
 
-  Using <tt/-Os/ will force the compiler to inline some known functions from
-  the C library like strlen. Note: This has two consequences:
-  <p>
-  <itemize>
-  <item>You may not use names of standard C functions in your own code. If you
-       do that, your program is not standard compliant anyway, but using
-       <tt/-Os/ will actually break things.
-       <p>
-  <item>The inlined string and memory functions will not handle strings or
-       memory areas larger than 255 bytes. Similarly, the inlined <tt/is..()/
-       functions will not work with values outside the char. range (such as
-       <tt/EOF/).
-       <p>
-  </itemize>
-  <p>
+  Using <tt/-Os/ will allow the compiler to inline some standard functions
+  from the C library like strlen.  This will not only remove the overhead
+  for a function call, but will make the code visible for the optimizer.
+  See also the <tt/<ref id="option-inline-stdfuncs" name="--inline-stdfuncs">/
+  command line option.
+
   It is possible to concatenate the modifiers for <tt/-O/. For example, to
-  enable register variables and inlining of known functions, you may use
+  enable register variables and inlining of standard functions, you may use
   <tt/-Ors/.
 
 
@@ -518,6 +553,7 @@ Here is a description of all the command line options:
 </descrip><p>
 
 
+
 <sect>Input and output<p>
 
 The compiler will accept one C file per invocation and create a file with
@@ -556,21 +592,21 @@ and the one defined by the ISO standard:
 
 <itemize>
 
-<item> The datatypes "float" and "double" are not available.
-       <p>
-<item>         C Functions may not return structs (or unions), and structs may not
+<item>  The datatypes "float" and "double" are not available.
+        <p>
+<item>  C Functions may not return structs (or unions), and structs may not
         be passed as parameters by value. However, struct assignment *is*
-       possible.
-       <p>
-<item> Most of the C library is available with only the fastcall calling
-       convention (<ref id="extension-fastcall" name="see below">).  It means
-       that you must not mix pointers to those functions with pointers to
-       user-written, cdecl functions (the calling conventions are incompatible).
-       <p>
-<item> The <tt/volatile/ keyword has almost no effect. That is not as bad
+        possible.
+        <p>
+<item>  Most of the C library is available with only the fastcall calling
+        convention (<ref id="extension-fastcall" name="see below">).  It means
+        that you must not mix pointers to those functions with pointers to
+        user-written, cdecl functions (the calling conventions are incompatible).
+        <p>
+<item>  The <tt/volatile/ keyword has almost no effect. That is not as bad
         as it sounds, since the 6502 has so few registers that it isn't
         possible to keep values in registers anyway.
-       <p>
+        <p>
 </itemize>
 
 There may be some more minor differences I'm currently not aware of. The
@@ -585,49 +621,48 @@ This cc65 version has some extensions to the ISO C standard.
 
 <itemize>
 
-<item> The compiler allows to insert assembler statements into the output
-       file. The syntax is
+<item>  The compiler allows to insert assembler statements into the output
+        file. The syntax is
 
-       <tscreen><verb>
-       asm [optional volatile] (&lt;string literal&gt;[, optional parameters]) ;
-       </verb></tscreen>
-       or
-       <tscreen><verb>
+        <tscreen><verb>
+        asm [optional volatile] (&lt;string literal&gt;[, optional parameters]) ;
+        </verb></tscreen>
+        or
+        <tscreen><verb>
         __asm__ [optional volatile] (&lt;string literal&gt;[, optional parameters]) ;
-       </verb></tscreen>
+        </verb></tscreen>
 
-       The first form is in the user namespace; and, is disabled if the <tt/-A/
-       switch is given.
+        The first form is in the user namespace; and, is disabled if the <tt/-A/
+        switch is given.
 
-       There is a whole section covering inline assembler statements,
-       <ref id="inline-asm" name="see there">.
-       <p>
+        There is a whole section covering inline assembler statements,
+        <ref id="inline-asm" name="see there">.
+        <p>
 
 <label id="extension-fastcall">
-<item> The normal calling convention -- for non-variadic functions -- is
-       named "fastcall". The syntax for a function declaration that
-       <em/explicitly/ uses fastcall is
-
-       <tscreen><verb>
-       &lt;return type&gt; fastcall &lt;function name&gt; (&lt;parameter list&gt;)
-       </verb></tscreen>
-       or
-       <tscreen><verb>
-       &lt;return type&gt; __fastcall__ &lt;function name&gt; (&lt;parameter list&gt;)
-       </verb></tscreen>
-       An example is
-       <tscreen><verb>
-       void __fastcall__ f (unsigned char c)
-       </verb></tscreen>
-       The first form of the fastcall keyword is in the user namespace and can
-       therefore be disabled with the <tt><ref id="option--standard"
+<item>  The normal calling convention -- for non-variadic functions -- is
+        named "fastcall". The syntax for a function declaration that
+        <em/explicitly/ uses fastcall is
+
+        <tscreen><verb>
+        &lt;return type&gt; fastcall &lt;function name&gt; (&lt;parameter list&gt;)
+        </verb></tscreen>
+        or
+        <tscreen><verb>
+        &lt;return type&gt; __fastcall__ &lt;function name&gt; (&lt;parameter list&gt;)
+        </verb></tscreen>
+        An example is
+        <tscreen><verb>
+        void __fastcall__ f (unsigned char c)
+        </verb></tscreen>
+        The first form of the fastcall keyword is in the user namespace and can
+        therefore be disabled with the <tt><ref id="option--standard"
         name="--standard"></tt> command line option.
 
-       For functions that are <tt/fastcall/, the rightmost parameter is not
-       pushed on the stack but left in the primary register when the function
-       is called. That significantly reduces the cost of calling those functions.
-       <newline><newline>
-       <p>
+        For functions that are <tt/fastcall/, the rightmost parameter is not
+        pushed on the stack but left in the primary register when the function
+        is called. That significantly reduces the cost of calling those functions.
+        <p>
 
 <item>  There is another calling convention named "cdecl". Variadic functions
         (their prototypes have an ellipsis &lsqb;<tt/.../&rsqb;) always use that
@@ -652,65 +687,72 @@ This cc65 version has some extensions to the ISO C standard.
         For functions that are <tt/cdecl/, the rightmost parameter is pushed
         onto the stack before the function is called. That increases the cost
         of calling those functions, especially when they are called from many
-        places.<newline><newline>
+        places.
         <p>
 
-<item> There are two pseudo variables named <tt/__AX__/ and <tt/__EAX__/.
-       Both refer to the primary register that is used by the compiler to
-       evaluate expressions or return function results. <tt/__AX__/ is of
-       type <tt/unsigned int/ and <tt/__EAX__/ of type <tt/long unsigned int/
-       respectively. The pseudo variables may be used as lvalue and rvalue as
-       every other variable. They are most useful together with short
-       sequences of assembler code. For example, the macro
+<item>  There are two pseudo variables named <tt/__AX__/ and <tt/__EAX__/.
+        Both refer to the primary register that is used by the compiler to
+        evaluate expressions or return function results. <tt/__AX__/ is of
+        type <tt/unsigned int/ and <tt/__EAX__/ of type <tt/long unsigned int/
+        respectively. The pseudo variables may be used as lvalue and rvalue as
+        every other variable. They are most useful together with short
+        sequences of assembler code. For example, the macro
 
-       <tscreen><verb>
-               #define hi(x)           \
+        <tscreen><verb>
+        #define hi(x)           \
             (__AX__ = (x),      \
              asm ("txa"),       \
              asm ("ldx #$00"),  \
              __AX__)
-       </verb></tscreen>
+        </verb></tscreen>
+
+        will give the high byte of any unsigned value.
+        <p>
+
+<item>  Inside a function, the identifier <tt/__func__/ gives the name of the
+        current function as a string. Outside of functions, <tt/__func__/ is
+        undefined.
+        Example:
 
-       will give the high byte of any unsigned value.
-       <p>
+        <tscreen><verb>
+        #define PRINT_DEBUG(s)  printf ("%s: %s\n", __func__, s);
+        </verb></tscreen>
 
-<item> Inside a function, the identifier <tt/__func__/ gives the name of the
-       current function as a string. Outside of functions, <tt/__func__/ is
-       undefined.
-       Example:
+        The macro will print the name of the current function plus a given
+        string.
+        <p>
 
-       <tscreen><verb>
-       #define PRINT_DEBUG(s)  printf ("%s: %s\n", __func__, s);
-       </verb></tscreen>
+<item>  cc65 allows the initialization of <tt/void/ variables. This may be
+        used to create arbitrary structures that are more compatible with
+        interfaces written for assembler languages. Here is an example:
 
-       The macro will print the name of the current function plus a given
-       string.
-       <p>
+        <tscreen><verb>
+        void GCmd = { (char)3, (unsigned)0x2000, (unsigned)0x3000 };
+        </verb></tscreen>
 
-<item>         cc65 allows the initialization of <tt/void/ variables. This may be
-       used to create variable structures that are more compatible with
-       interfaces written for assembler languages. Here is an example:
+        That will be translated as follows:
 
-       <tscreen><verb>
-       void GCmd = {   (char)3, (unsigned)0x2000, (unsigned)0x3000 };
-       </verb></tscreen>
+        <tscreen><verb>
+        _GCmd:
+                .byte   3
+                .word   $2000
+                .word   $3000
+        </verb></tscreen>
 
-       This will be translated as follows:
+        Since the variable is of type <tt/void/, you may not use it as-is.
+        However, taking the address of the variable results in a <tt/void*/
+        which may be passed to any function expecting a pointer.  Also, the
+        <tt/sizeof/ operator will give the length of the initializer:
 
-       <tscreen><verb>
-       _GCmd:
-               .byte   3
-               .word   $2000
-               .word   $3000
-       </verb></tscreen>
+        <tscreen><verb>
+        GLen = sizeof GCmd;
+        </verb></tscreen>
 
-       Since the variable is of type <tt/void/ you may not use it as is.
-       However, taking the address of the variable results in a <tt/void*/
-       which may be passed to any function expecting a pointer.
+        will assign the value 5 to <tt/GLen/.
 
-       See the <url url="geos.html" name="GEOS library document"> for examples
-       on how to use this feature.
-       <p>
+        See the <url url="geos.html" name="GEOS library document"> for examples
+        on how to use that feature.
+        <p>
 
 <item>  cc65 implements flexible array struct members as defined in the C99 ISO
         standard. As an extension, these fields may be initialized. There are
@@ -818,6 +860,11 @@ The compiler defines several macros at startup:
   This macro expands to the date of translation of the preprocessing
   translation unit in the form "Mmm dd yyyy".
 
+  <tag><tt>__EAGERLY_INLINE_FUNCS__</tt></tag>
+
+  Is defined if the compiler was called with the <tt><ref id="option-eagerly-inline-funcs"
+  name="--eagerly-inline-funcs"></tt> command line option.
+
   <tag><tt>__FILE__</tt></tag>
 
   This macro expands to a string containing the name of the C source file.
@@ -905,6 +952,7 @@ The compiler defines several macros at startup:
 </descrip>
 
 
+
 <sect>&num;pragmas<label id="pragmas"><p>
 
 The compiler understands some pragmas that may be used to change code
@@ -913,6 +961,19 @@ If the first parameter is <tt/push/, the old value is saved onto a stack
 before changing it. The value may later be restored by using the <tt/pop/
 parameter with the <tt/#pragma/.
 
+
+<sect1><tt>#pragma allow-eager-inline ([push,] on|off)</tt><label id="pragma-allow-eager-inline"><p>
+
+  Allow eager inlining of known functions.  If the argument is "off", eager
+  inlining is disabled, otherwise it is enabled. Please note that (in contrast
+  to the <tt><ref id="option-eagerly-inline-funcs" name="--eagerly-inline-funcs"></tt>
+  command line option) this pragma does not imply the <tt><ref id="option-inline-stdfuncs"
+  name="--inline-stdfuncs"></tt> command line option.  Rather it marks code to be safe for
+  eager inlining of known functions if inlining of standard functions is enabled.
+
+  The <tt/#pragma/ understands the push and pop parameters as explained above.
+
+
 <sect1><tt>#pragma bss-name (&lsqb;push,&rsqb; &lt;name&gt;)</tt><label id="pragma-bss-name"><p>
 
   This pragma changes the name used for the BSS segment (the BSS segment
@@ -931,7 +992,7 @@ parameter with the <tt/#pragma/.
 
   Example:
   <tscreen><verb>
-               #pragma bss-name ("MyBSS")
+        #pragma bss-name ("MyBSS")
   </verb></tscreen>
 
 
@@ -986,6 +1047,7 @@ parameter with the <tt/#pragma/.
 
   The <tt/#pragma/ understands the push and pop parameters as explained above.
 
+
 <sect1><tt>#pragma code-name ([push,] &lt;name&gt;)</tt><label id="pragma-code-name"><p>
 
   This pragma changes the name used for the CODE segment (the CODE segment
@@ -1000,7 +1062,7 @@ parameter with the <tt/#pragma/.
 
   Example:
   <tscreen><verb>
-               #pragma code-name ("MyCODE")
+        #pragma code-name ("MyCODE")
   </verb></tscreen>
 
 
@@ -1028,10 +1090,21 @@ parameter with the <tt/#pragma/.
 
   Example:
   <tscreen><verb>
-               #pragma data-name ("MyDATA")
+        #pragma data-name ("MyDATA")
   </verb></tscreen>
 
 
+<sect1><tt>#pragma inline-stdfuncs ([push,] on|off)</tt><label id="pragma-inline-stdfuncs"><p>
+
+  Allow the compiler to inline some standard functions from the C library like
+  strlen.  If the argument is "off", inlining is disabled, otherwise it is enabled.
+
+  See also the <tt/<ref id="option-inline-stdfuncs" name="--inline-stdfuncs">/
+  command line option.
+
+  The <tt/#pragma/ understands the push and pop parameters as explained above.
+
+
 <sect1><tt>#pragma local-strings ([push,] on|off)</tt><label id="pragma-local-strings"><p>
 
   When "on", emit string literals to the data segment when they're encountered
@@ -1046,6 +1119,23 @@ parameter with the <tt/#pragma/.
   remembered and output as a whole when translation is finished.
 
 
+<sect1><tt>#pragma message (&lt;message&gt;)</tt><label id="pragma-message"><p>
+
+  This pragma is used to display informational messages at compile-time.
+
+  The message intented to be displayed must be a string literal.
+
+  Example:
+  <tscreen><verb>
+        #pragma message ("in a bottle")
+  </verb></tscreen>
+
+  Results in the compiler outputting the following to stderr:
+  <tscreen><verb>
+        example.c(42): Note: in a bottle
+  </verb></tscreen>
+
+
 <sect1><tt>#pragma optimize ([push,] on|off)</tt><label id="pragma-optimize"><p>
 
   Switch optimization on or off. If the argument is "off", optimization is
@@ -1076,7 +1166,7 @@ parameter with the <tt/#pragma/.
 
   Example:
   <tscreen><verb>
-               #pragma rodata-name ("MyRODATA")
+        #pragma rodata-name ("MyRODATA")
   </verb></tscreen>
 
 
@@ -1098,9 +1188,9 @@ parameter with the <tt/#pragma/.
 
   Example:
   <tscreen><verb>
-               #pragma regvaraddr(on)  /* Allow taking the address
-                                        * of register variables
-                                        */
+        #pragma regvaraddr(on)  /* Allow taking the address
+                                 * of register variables
+                                 */
   </verb></tscreen>
 
 
@@ -1147,7 +1237,7 @@ parameter with the <tt/#pragma/.
   Example:
   <tscreen><verb>
         /* Don't warn about the unused parameter in function func */
-       #pragma warn (unused-param, push, off)
+        #pragma warn (unused-param, push, off)
         static int func (int unused)
         {
             return 0;
@@ -1156,6 +1246,39 @@ parameter with the <tt/#pragma/.
   </verb></tscreen>
 
 
+<sect1><tt>#pragma wrapped-call (push, &lt;name&gt;, &lt;identifier&gt;)</tt><label id="pragma-wrapped-call"><p>
+
+  This pragma sets a wrapper for functions, often used for trampolines.
+
+  The name is a function returning <tt/void/, and taking no parameters.
+  It must preserve the CPU's <tt/A/ and <tt/X/ registers if it wraps any
+  <tt/__fastcall__/ functions that have parameters.  It must preserve
+  the <tt/Y/ register if it wraps any variadic functions (they have "<tt/.../"
+  in their prototypes).
+
+  The identifier is an 8-bit number that's set into <tt/tmp4/.
+
+  The address of a wrapped function is passed in <tt/ptr4/.  The wrapper can
+  call that function by using "<tt/jsr callptr4/".
+
+  This feature is useful, for example, with banked memory, to switch banks
+  automatically to where a wrapped function resides, and then to restore the
+  previous bank when it returns.
+
+  The <tt/#pragma/ requires the push or pop argument as explained above.
+
+  Example:
+  <tscreen><verb>
+/* Note that this code can be in a header. */
+void mytrampoline(void); /* Doesn't corrupt __AX__ */
+
+#pragma wrapped-call (push, mytrampoline, 5)
+void somefunc1(void);
+void somefunc2(int, char *);
+#pragma wrapped-call (pop)
+  </verb></tscreen>
+
+
 <sect1><tt>#pragma writable-strings ([push,] on|off)</tt><label id="pragma-writable-strings"><p>
 
   Changes the storage location of string literals. For historical reasons,
@@ -1180,13 +1303,12 @@ parameter with the <tt/#pragma/.
 
   Example:
   <tscreen><verb>
-       extern int foo;
-       #pragma zpsym ("foo");  /* foo is in the zeropage */
+        extern int foo;
+        #pragma zpsym ("foo");  /* foo is in the zeropage */
   </verb></tscreen>
 
 
 
-
 <sect>Register variables<label id="register-vars"><p>
 
 The runtime for all supported platforms has 6 bytes of zero page space
@@ -1269,7 +1391,7 @@ that function).
 As a shortcut, you can put the <tt/volatile/ qualifier in your <tt/asm/
 statements.  It will disable optimization for the functions in which those
 <tt/asm volatile/ statements sit.  The effect is the same as though you put
-</#pragma optimize(push, off)/ above those functions, and </#pragma
+<tt/#pragma optimize(push, off)/ above those functions, and <tt/#pragma
 optimize(pop)/ below those functions.
 
 The string literal may contain format specifiers from the following list. For
@@ -1443,14 +1565,14 @@ including commercial applications, and to alter it and redistribute it
 freely, subject to the following restrictions:
 
 <enum>
-<item>         The origin of this software must not be misrepresented; you must not
-               claim that you wrote the original software. If you use this software
-               in a product, an acknowledgment in the product documentation would be
-       appreciated but is not required.
-<item> Altered source versions must be plainly marked as such, and must not
-       be misrepresented as being the original software.
-<item> This notice may not be removed or altered from any source
-       distribution.
+<item>  The origin of this software must not be misrepresented; you must not
+        claim that you wrote the original software. If you use this software
+        in a product, an acknowledgment in the product documentation would be
+        appreciated but is not required.
+<item>  Altered source versions must be plainly marked as such, and must not
+        be misrepresented as being the original software.
+<item>  This notice may not be removed or altered from any source
+        distribution.
 </enum>
 
 </article>
index eef6a12a34974b6a66e2cf5cf27cf0616c5b8ef5..ca5f9d2af84d45dc1424c8b8116627cc14f0207c 100644 (file)
@@ -2,8 +2,9 @@
 
 <article>
 <title>cl65 Users Guide
-<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">
-<date>01.08.2000, 27.11.2000, 02.10.2001
+<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline>
+<url url="mailto:greg.king5@verizon.net" name="Greg King">
+<date>2017-10-16
 
 <abstract>
 cl65 is the compile &amp; link utility for cc65, the 6502 C compiler. It was
@@ -50,13 +51,14 @@ Short options:
   -C name                       Use linker config file
   -Cl                           Make local variables static
   -D sym[=defn]                 Define a preprocessor symbol
+  -E                            Stop after the preprocessing stage
   -I dir                        Set a compiler include directory path
   -L path                       Specify a library search path
   -Ln name                      Create a VICE label file
   -O                            Optimize code
-  -Oi                           Optimize code, inline functions
+  -Oi                           Optimize code, inline more code
   -Or                           Optimize code, honour the register keyword
-  -Os                           Optimize code, inline known C funtions
+  -Os                           Optimize code, inline standard funtions
   -S                            Compile but don't assemble and link
   -T                            Include source as comment
   -V                            Print the version number
@@ -67,6 +69,7 @@ Short options:
 
 Long options:
   --add-source                  Include source as comment
+  --all-cdecl                   Make functions default to __cdecl__
   --asm-args options            Pass options to the assembler
   --asm-define sym[=v]          Define an assembler symbol
   --asm-include-dir dir         Set an assembler include directory
@@ -120,56 +123,66 @@ Long options:
 ---------------------------------------------------------------------------
 </verb></tscreen>
 
-Most of the options have the same meaning than the corresponding compiler,
-assembler or linker option. See the documentation for these tools for an
+Most of the options have the same meanings as the corresponding compiler,
+assembler, and linker options. See the documentation for those tools for an
 explanation. If an option is available for more than one of the tools, it
-is set for all tools, where it is available. One example for this is <tt/-v/:
-The compiler, the assembler and the linker are all called with the <tt/-v/
+is set for all tools where it is available. One example for that is <tt/-v/:
+The compiler, the assembler, and the linker are all called with the <tt/-v/
 switch.
 
 There are a few remaining options that control the behaviour of cl65:
 
 <descrip>
 
+  <tag><tt>-E</tt></tag>
+
+  This option is passed to the cc65 compiler; and, it forces cl65 to stop
+  before the assembly step. That means that C-level preprocessor directives
+  are obeyed; and, macroes are expanded.  But, the C source isn't compiled.
+  If the <tt/-o/ option isn't used, then the C code results are written into
+  files with a ".i" suffix on their base names.  Assembler files, object
+  files, and libraries given on the command line are ignored.
+
+
   <tag><tt>-S</tt></tag>
 
-  This option forces cl65 to stop after the assembly step. This means that
-  C files are translated into assembler files, but nothing more is done.
-  Assembler files, object files and libraries given on the command line
+  This option forces cl65 to stop before the assembly step. That means that
+  C files are translated into assembler files; but, nothing more is done.
+  Assembler files, object files, and libraries given on the command line
   are ignored.
 
 
   <tag><tt>-c</tt></tag>
 
-  This options forces cl65 to stop after the assembly step. This means
+  This option forces cl65 to stop after the assembly step. That means
   that C and assembler files given on the command line are translated into
-  object files, but there is no link step, and object files and libraries
+  object files; but, there is no link step.  Object files and libraries
   given on the command line are ignored.
 
 
   <tag><tt>-o name</tt></tag>
 
-  The -o option is used for the target name in the final step. This causes
-  problems, if the linker will not be called, and there are several input
-  files on the command line. In this case, the name given with -o will be
+  The -o option is used for the target name in the final step. That causes
+  problems if the linker will not be called, and there are several input
+  files on the command line. In that case, the name given with -o will be
   used for all of them, which makes the option pretty useless. You
-  shouldn't use -o when more than one output file is created.
+  shouldn't use <tt/-o/ when more than one output file is created.
 
 
   <tag><tt>--print-target-path</tt></tag>
 
-  This option prints the absolute path of the target file directory and exits
+  This option prints the absolute path of the target file directory, and exits
   then. It is supposed to be used with shell backquotes or the GNU make shell
-  function. This way you can write build scripts or Makefiles accessing target
+  function. That way, you can write build scripts or Makefiles accessing target
   files without any assumption about the cc65 installation path.
 
 
   <tag><tt>-t sys, --target sys</tt></tag>
 
-  The default for this option is different from the compiler and linker in the
-  case that the option is missing: While the other tools (compiler, assembler
+  The default for this option is different from the compiler and linker, in the
+  case that the option is missing:  While the other tools (compiler, assembler,
   and linker) will use the "none" system settings by default, cl65 will use
-  the C64 as a target system by default. This was chosen since most people
+  "c64" as a target system by default. That was chosen because most people
   seem to use cc65 to develop for the C64.
 
 
@@ -177,10 +190,10 @@ There are a few remaining options that control the behaviour of cl65:
 
   Pass options directly to the assembler. This may be used to pass options
   that aren't directly supported by cl65. Several options may be separated by
-  commas, the commas are replaced by spaces when passing them to the
-  assembler. Beware: Passing arguments directly to the assembler may interfere
-  with some of the defaults, because cl65 doesn't parse the options passed. So
-  if cl65 supports an option by itself, do not pass this option to the
+  commas; the commas are replaced by spaces when passing them to the
+  assembler. Beware: Passing arguments directly to the assembler might interfere
+  with some of the defaults because cl65 doesn't parse the options passed. So,
+  if cl65 supports an option by itself, do not pass that option to the
   assembler by means of the <tt/-Wa/ switch.
 
 
@@ -188,10 +201,10 @@ There are a few remaining options that control the behaviour of cl65:
 
   Pass options directly to the compiler. This may be used to pass options
   that aren't directly supported by cl65. Several options may be separated by
-  commas, the commas are replaced by spaces when passing them to the
-  compiler. Beware: Passing arguments directly to the compiler may interfere
-  with some of the defaults, because cl65 doesn't parse the options passed. So
-  if cl65 supports an option by itself, do not pass this option to the
+  commas; the commas are replaced by spaces when passing them to the
+  compiler. Beware: Passing arguments directly to the compiler might interfere
+  with some of the defaults because cl65 doesn't parse the options passed. So,
+  if cl65 supports an option by itself, do not pass that option to the
   compiler by means of the <tt/-Wc/ switch.
 
 
@@ -199,10 +212,10 @@ There are a few remaining options that control the behaviour of cl65:
 
   Pass options directly to the linker. This may be used to pass options that
   aren't directly supported by cl65. Several options may be separated by
-  commas, the commas are replaced by spaces when passing them to the linker.
-  Beware: Passing arguments directly to the linker may interfere with some of
-  the defaults, because cl65 doesn't parse the options passed. So if cl65
-  supports an option by itself, do not pass this option to the linker by means
+  commas; the commas are replaced by spaces when passing them to the linker.
+  Beware: Passing arguments directly to the linker might interfere with some of
+  the defaults because cl65 doesn't parse the options passed. So, if cl65
+  supports an option by itself, do not pass that option to the linker by means
   of the <tt/-Wl/ switch.
 
 </descrip>
@@ -211,7 +224,7 @@ There are a few remaining options that control the behaviour of cl65:
 
 <sect>More usage<p>
 
-Since cl65 was created to simplify the use of the cc65 development
+Because cl65 was created to simplify the use of the cc65 development
 package, it tries to be smart about several things.
 
 <itemize>
@@ -219,15 +232,14 @@ package, it tries to be smart about several things.
 <item> If you don't give a target system on the command line, cl65
        defaults to the C64.
 
-<item> When linking, cl65 will supply the names of the startup file and
-       library for the target system to the linker, so you don't have to do
-       that.
+<item>  When linking, cl65 will supply the name of the library file for
+        the target system to the linker; so, you don't have to do that.
 
 <item> If the final step is the linker, and the name of the output file was
        not explicitly given, cl65 will use the name of the first input file
-       without the extension, provided that the name of this file has an
-       extension. So you don't need to name the executable name in most
-       cases, just give the name of your "main" file as first input file.
+        without the extension, provided that the name of that file has an
+        extension. So, you don't need to give the executable name in most
+        cases; just give the name of your "main" file as the first input file.
 </itemize>
 
 The command line is parsed from left to right, and the actual processing tool
@@ -248,7 +260,7 @@ The type of an input file is derived from its extension:
 <itemize>
 <item>C files: <tt/.c/
 <item>Assembler files: <tt/.s/, <tt/.asm/, <tt/.a65/
-<item>Object files: <tt/.o/ <tt/.obj/
+<item>Object files: <tt/.o/, <tt/.obj/
 <item>Libraries: <tt/.a/, <tt/.lib/
 <item>GEOS resource files: <tt/.grc/
 <item>o65 files: <tt/.o65/, <tt/.emd/, <tt/.joy/, <tt/.tgi/
index d4c2f3fe1ba11fc3ee650879f2e8f393d0f5fd95..1d5ee7c192c46eeca60cba643cd55a7a95f8489b 100644 (file)
@@ -2,8 +2,9 @@
 
 <article>
 <title>cc65 function reference
-<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">
-<date>2016-08-07
+<author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline>
+<url url="mailto:greg.king5@verizon.net" name="Greg King">
+<date>2017-09-02
 
 <abstract>
 cc65 is a C compiler for 6502 based systems. This function reference describes
@@ -183,6 +184,7 @@ function.
 <!-- <item><ref id="cbm_save" name="cbm_save"> -->
 <!-- <item><ref id="cbm_write" name="cbm_write"> -->
 <!-- <item><ref id="get_tv" name="get_tv"> -->
+<item><ref id="kbrepeat" name="kbrepeat">
 </itemize>
 
 (incomplete)
@@ -398,6 +400,13 @@ function.
 (incomplete)
 
 
+<sect1><tt/lz4.h/<label id="lz4.h"><p>
+
+<itemize>
+<item><ref id="decompress_lz4" name="decompress_lz4">
+</itemize>
+
+
 <sect1><tt/modload.h/<label id="modload.h"><p>
 
 <itemize>
@@ -430,7 +439,7 @@ function.
 
 <!-- <itemize> -->
 <!-- <item><ref id="get_tv" name="get_tv"> -->
-<!-- <item><ref id="waitvblank" name="waitvblank"> -->
+<!-- <item><ref id="waitvsync" name="waitvsync"> -->
 <!-- </itemize> -->
 
 (incomplete)
@@ -2632,6 +2641,23 @@ used in presence of a prototype.
 </quote>
 
 
+<sect1>decompress_lz4<label id="decompress_lz4"><p>
+
+<quote>
+<descrip>
+<tag/Function/Uncompress a LZ4-compressed buffer.
+<tag/Header/<tt/<ref id="lz4.h" name="lz4.h">/
+<tag/Declaration/<tt/void decompress_lz4 (const unsigned char* src, unsigned char* const dst, const unsigned short uncompressed_size);/
+<tag/Description/<tt/decompress_lz4/ uncompresses a LZ4-compressed buffer.
+<tag/Notes/<itemize>
+<item>Use LZ4_compress_HC with compression level 16 for best compression.
+</itemize>
+<tag/Availability/cc65
+<tag/Example/None.
+</descrip>
+</quote>
+
+
 <sect1>div<label id="div"><p>
 
 <quote>
@@ -3710,7 +3736,7 @@ fastcall function, so it may only be used in presence of a prototype.
 
 <quote>
 <descrip>
-<tag/Function/Check if a given character is a white-space character.
+<tag/Function/Check if a given character is a white-space character.
 <tag/Header/<tt/<ref id="ctype.h" name="ctype.h">/
 <tag/Declaration/<tt/int __fastcall__ isspace (int c);/
 <tag/Description/The function returns a non zero value if the given argument
@@ -4017,6 +4043,28 @@ do), the function is rather useless.
 </quote>
 
 
+<sect1>kbrepeat<label id="kbrepeat"><p>
+
+<quote>
+<descrip>
+<tag/Function/Set the keyboard repeat mode.
+<tag/Header/<tt/<ref id="cbm.h" name="cbm.h">/
+<tag/Declaration/<tt/unsigned char __fastcall__ kbrepeat (unsigned char mode);/
+<tag/Description/This function changes which keys have automatic repeat when
+being held down for a certain time. Possible values are <tt/KBREPEAT_CURSOR/
+(repeat only cursor-related keys), <tt/KBREPEAT_NONE/ (no repeat for any
+keys), and <tt/KBREPEAT_ALL/ (repeat all keys). The old mode is returned, so
+it can be restored later.
+<tag/Notes/<itemize>
+<item>The function is available only as a fastcall function; so, it may be used
+only in the presence of a prototype.
+</itemize>
+<tag/Availability/cc65
+<tag/Example/None.
+</descrip>
+</quote>
+
+
 <sect1>labs<label id="labs"><p>
 
 <quote>
index 5687aa8abc851bd57202e99f7dcc35b0aad253c1..8f9dd709341e28d361ac5ed14179f2283f6909ba 100644 (file)
@@ -247,10 +247,11 @@ Here is a description of all of the command-line options:
   <tag><tt>-Ln</tt></tag>
 
   This option allows you to create a file that contains all global labels and
-  may be loaded into the VICE emulator using the <tt/ll/ (load label) command. You
+  may be loaded into the VICE emulator using the <tt/ll/ (load label) command
+  or into the Oricutron emulator using the <tt/sl/ (symbols load) command. You
   may use this to debug your code with VICE. Note: Older versions had some
   bugs in the label code. If you have problems, please get the latest <url
-  url="http://vice-emu.sourceforge.net/" name="VICE"> version.
+  url="http://vice-emu.sourceforge.net" name="VICE"> version.
 
 
   <label id="option-S">
index 98c25b6af934faebfab7f4bf3446f8f5fde2433b..8f4374e055b998cb1c4bdaa38d232c830f43cb48 100644 (file)
@@ -69,8 +69,8 @@ Programs containing NES specific code may use the <tt/nes.h/ header file.
 <sect1>NES specific functions<p>
 
 <itemize>
-<item>waitvblank - wait until the start of vblank
-<item>get_tv
+<item>waitvsync - wait until the start of the next frame</item>
+<item>get_tv</item>
 </itemize>
 
 
index 104dee52621ebdea8ff0579b5b542bec6e643905..927df8f5cdd9ae2c6d7a036043603b8272ae0cf6 100644 (file)
@@ -77,7 +77,7 @@ Programs containing PCE specific code may use the <tt/pce.h/ header file.
 <sect1>PCE specific functions<p>
 
 <itemize>
-<item>waitvblank</item>
+<item>waitvsync</item>
 <item>get_tv (since all PCE systems are NTSC, this always returns TV_NTSC)</item>
 </itemize>
 
index 97495dea58d2a8ef56d96b0350347f66c29a2688..cf2af79672b59800e8fcb1a07528039d11c2fa94 100644 (file)
@@ -66,7 +66,7 @@ Programs containing Supervision specific code may use the <tt/supervision.h/ hea
 <sect1>Supervision specific functions<p>
 
 <itemize>
-<item>waitvblank
+<item>waitvsync</item>
 </itemize>
 
 
index 0c85c68c5da0cc8a800a370ec900f5987b91985a..2d05f898539648e432ec553c40349566bc7243d1 100644 (file)
@@ -4,13 +4,15 @@
 
 <title>Oric Telestrat-specific information for cc65
 <author>
-<url url="mailto:jede@oric.org" name="Jede">,<newline>
+<url url="mailto:jede@oric.org" name="Jede">
 
 <date>2017-01-22
 
 <abstract>
+
 An overview over the Telestrat (Telemon 2.4 & Telemon 3.x : http://orix.oric.org) runtime system as it is implemented for the cc65 C
 compiler.)
+
 </abstract>
 
 <!-- Table of contents -->
@@ -32,25 +34,28 @@ information.
 
 <sect>Binary format<p>
 
-The standard binary output format generated the linker for the Telestrat target
-is a machine language program with a 20 bytes header described here : http://orix.oric.org/doku.php?id=orix:header 
+The standard binary output format generated the linker for the Telestrat
+target is a machine language program with a 20 bytes header described <url
+name="here" url="http://orix.oric.org/doku.php?id=orix:header">
 
-This header is used for Telemon 3.0. 
+This header is used for Telemon 3.0.
 
-Anyway, for Telemon 2.4, there is no file management, there is no TAPE routine in Telemon, there is no way to load a binary easily. 
+Anyway, for Telemon 2.4, there is no file management, there is no TAPE routine in Telemon, there is no way to load a binary easily.
 
-Stratsed (the Telestrat operating system) handles files management. Stratsed is loaded to memory from floppy disk. 
+Stratsed (the Telestrat operating system) handles files management. Stratsed is loaded to memory from floppy disk.
 
-There is no tool to insert a binary in a Stratsed floppy disk. 
+There is no tool to insert a binary in a Stratsed floppy disk.
 
-The only way to load a binary (for Telemon 2.4) is to :
+The only way to load a binary (for Telemon 2.4) is to:
 <itemize>
 <item>remove the 20 bytes header
-<item>download osdk : http://osdk.defence-force.org/index?page=download
+<item>download <url name="osdk" url="http://osdk.defence-force.org/index?page=download">
 <item>use Floppybuilder in OSDK to insert the binary with the tool (please read FloppyBuilder manual to insert your binary, and to start microdisc boot sector when Telestrat starts)
 </itemize>
 
-Please note also, that the binary converted into TAP file, will not produce a right stratsed file when tap2dsk and old2mfm are used. You will be in the case that Telestrat/Stratsed crashed when you do "DIR" command.
+Please note also, that the binary converted into TAP file, will not produce
+a right stratsed file when tap2dsk and old2mfm are used. You will be in the
+case that Telestrat/Stratsed crashed when you do "DIR" command.
 
 If you know the Stratsed disk format, please contact the author of this doc.
 
@@ -79,7 +84,7 @@ Special locations:
 
 <sect>Platform-specific header files<p>
 
-Programs containing Telestrat -specific code may use the <tt/telestrat.h/ header file.
+Programs containing Telestrat-specific code may use the <tt/telestrat.h/ header file.
 
 
 <sect1>Telestrat-specific functions<p>
@@ -162,8 +167,12 @@ Telestrat has a RS232 port, but it's not usable in cc65.
 
 <sect1>Disk I/O<p>
 
-Telemon 3.0 handles fopen, fread, fclose primitives. It means that this function will crash the Telestrat because Telemon 2.4 does not have these primitives.
-By the way, Telemon 3.0 uses an extension "ch376 card" which handles sdcard and FAT 32 usb key. In the next version of Telemon, FT DOS, Sedoric, Stratsed will be handled in these 3 primitives (fopen, fread, fclose).
+Telemon 3.0 handles fopen, fread, fclose primitives. It means that this
+function will crash the Telestrat because Telemon 2.4 does not have these
+primitives. By the way, Telemon 3.0 uses an extension "ch376 card" which
+handles sdcard and FAT 32 usb key. In the next version of Telemon, FT DOS,
+Sedoric, Stratsed will be handled in these 3 primitives (fopen, fread,
+fclose).
 
 <itemize>
 <item>fclose
index b1a08ac83bb56b8e7237290d2f31dc660b6afe42..26a4aa55829d8ee8f7bfbfbb66248e711a4c6c01 100644 (file)
@@ -2,11 +2,11 @@
 
 <article>
 
-<title>Commodore VIC20 (aka VC20) specific information for cc65
+<title>Commodore VIC20 (aka VC20 aka VIC1001) specific information for cc65
 <author>
 <url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline>
 <url url="mailto:polluks@sdf.lonestar.org" name="Stefan A. Haubenthal">
-<date>2014-04-12
+<date>2017-05-18
 
 <abstract>
 An overview over the VIC20 runtime system as it is implemented for the cc65 C
@@ -182,13 +182,14 @@ No VIC1011 drivers are currently available for the VIC20.
 <sect>Limitations<p>
 
 
+<sect1>Escape code<p>
 
-<sect>Other hints<p>
+The CTRL key cannot be used to type most control characters,
+entering an Esc is not possible.
 
 
-<sect1>Escape code<p>
 
-For an Esc, press CTRL and the <tt/[/ key.
+<sect>Other hints<p>
 
 
 <sect1>Passing arguments to the program<p>
@@ -219,8 +220,7 @@ The program return code (low byte) is passed back to BASIC by use of the
 
 <sect1>Using extended memory<p>
 
-The extended memory at $A000 may be added to the heap by using the following
-code:
+BLK5 memory may be added to the heap by using the following code:
 
 <tscreen><verb>
     /* Check for the existence of RAM */
index a1b094d4d3d8073941e72be2ca7d2bf22b02755d..421b5db6c9caa4a44886dc9a6399493480d44f5a 100644 (file)
@@ -42,6 +42,7 @@
 #endif
 
 
+#include <apple2_filetype.h>
 
 /*****************************************************************************/
 /*                                   Data                                    */
 #define CH_RTEE      '+'
 #define CH_CROSS     '+'
 
+/* Masks for joy_read */
+#define JOY_UP_MASK     0x10
+#define JOY_DOWN_MASK   0x20
+#define JOY_LEFT_MASK   0x04
+#define JOY_RIGHT_MASK  0x08
+#define JOY_BTN_1_MASK  0x40
+#define JOY_BTN_2_MASK  0x80
+
 /* Return codes for get_ostype */
 #define APPLE_UNKNOWN  0x00
 #define APPLE_II       0x10  /* Apple ][                    */
@@ -136,11 +145,9 @@ extern unsigned char _dos_type;
 
 
 /* The file stream implementation and the POSIX I/O functions will use the
-** following variables to determine the file type, aux type and creation time
-** stamp to use.
+** following struct to set the date and time stamp on files. This specificially
+** applies to the open and fopen functions.
 */
-extern unsigned char _filetype;  /* Default: 6 */
-extern unsigned int _auxtype;    /* Default: 0 */
 extern struct {
     struct {
         unsigned day  :5;
diff --git a/include/apple2_filetype.h b/include/apple2_filetype.h
new file mode 100644 (file)
index 0000000..83a44f5
--- /dev/null
@@ -0,0 +1,322 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                             apple2_filetype.h                             */
+/*                                                                           */
+/*                       Apple ][ file type definitions                      */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2017  Bill Chatfield, <bill_chatfield@yahoo.com>                      */
+/*                                                                           */
+/*                                                                           */
+/* This software is provided 'as-is', without any expressed or implied       */
+/* warranty.  In no event will the authors be held liable for any damages    */
+/* arising from the use of this software.                                    */
+/*                                                                           */
+/* Permission is granted to anyone to use this software for any purpose,     */
+/* including commercial applications, and to alter it and redistribute it    */
+/* freely, subject to the following restrictions:                            */
+/*                                                                           */
+/* 1. The origin of this software must not be misrepresented; you must not   */
+/*    claim that you wrote the original software. If you use this software   */
+/*    in a product, an acknowledgment in the product documentation would be  */
+/*    appreciated but is not required.                                       */
+/* 2. Altered source versions must be plainly marked as such, and must not   */
+/*    be misrepresented as being the original software.                      */
+/* 3. This notice may not be removed or altered from any source              */
+/*    distribution.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+
+
+#ifndef _APPLE2_FILETYPE_H
+#define _APPLE2_FILETYPE_H
+
+
+
+/* Check for errors */
+#if !defined(__APPLE2__)
+#  error This module may only be used when compiling for the Apple ][!
+#endif
+
+
+
+/*****************************************************************************/
+/*                                   Data                                    */
+/*****************************************************************************/
+
+
+
+/* ProDOS general file types */
+#define PRODOS_T_UNK    0x00    /* Unknown                      */
+#define PRODOS_T_BAD    0x01    /* Bad blocks                   */
+#define PRODOS_T_PCD    0x02    /* Pascal code                  */
+#define PRODOS_T_PTX    0x03    /* Pascal text                  */
+#define PRODOS_T_TXT    0x04    /* ASCII text                   */
+#define PRODOS_T_PDA    0x05    /* Pascal data                  */
+#define PRODOS_T_BIN    0x06    /* Binary                       */
+#define PRODOS_T_FNT    0x07    /* Apple III font               */
+#define PRODOS_T_FOT    0x08    /* Hi-res, dbl hi-res graphics  */
+#define PRODOS_T_BA3    0x09    /* Apple III BASIC program      */
+#define PRODOS_T_DA3    0x09    /* Apple III BASIC data         */
+#define PRODOS_T_WPF    0x0A    /* Generic word processing      */
+#define PRODOS_T_SOS    0x0B    /* SOS system                   */
+#define PRODOS_T_DIR    0x0F    /* ProDOS directory             */
+
+/* ProDOS productivity file types */
+#define PRODOS_T_RPD    0x10    /* RPS data                     */
+#define PRODOS_T_RPI    0x11    /* RPS index                    */
+#define PRODOS_T_AFD    0x12    /* AppleFile discard            */
+#define PRODOS_T_AFM    0x13    /* AppleFile model              */
+#define PRODOS_T_AFR    0x14    /* AppleFile report             */
+#define PRODOS_T_SCL    0x15    /* Screen library               */
+#define PRODOS_T_PFS    0x16    /* PFS document                 */
+#define PRODOS_T_ADB    0x19    /* AppleWorks database          */
+#define PRODOS_T_AWP    0x1A    /* AppleWorks word processing   */
+#define PRODOS_T_ASP    0x1B    /* AppleWorks spreadsheet       */
+
+/* ProDOS code file types */
+#define PRODOS_T_TDM    0x20    /* Desktop Manager              */
+#define PRODOS_T_IPS    0x21    /* Instant Pascal source        */
+#define PRODOS_T_UPV    0x22    /* USCD Pascal volume           */
+#define PRODOS_T_3SD    0x29    /* SOS directory                */
+#define PRODOS_T_8SC    0x2A    /* Source code                  */
+#define PRODOS_T_8OB    0x2B    /* Object code                  */
+#define PRODOS_T_8IC    0x2C    /* Interpreted code             */
+#define PRODOS_T_8LD    0x2D    /* Language data                */
+#define PRODOS_T_P8C    0x2E    /* ProDOS 8 code module         */
+
+/* ProDOS miscellaneous file types */
+#define PRODOS_T_OCR    0x41    /* Optical char recognition     */
+#define PRODOS_T_FTD    0x42    /* File type definitions        */
+
+/* ProDOS Apple IIgs general file types */
+#define PRODOS_T_GWP    0x50    /* Apple IIgs word processing   */
+#define PRODOS_T_GSS    0x51    /* Apple IIgs spreadsheet       */
+#define PRODOS_T_GDB    0x52    /* Apple IIgs database          */
+#define PRODOS_T_DRW    0x53    /* Object oriented graphics     */
+#define PRODOS_T_GDP    0x54    /* Apple IIgs desktop publish   */
+#define PRODOS_T_HMD    0x55    /* HyperMedia                   */
+#define PRODOS_T_EDU    0x56    /* Educational program data     */
+#define PRODOS_T_STN    0x57    /* Stationary                   */
+#define PRODOS_T_HLP    0x58    /* Help                         */
+#define PRODOS_T_COM    0x59    /* Communications               */
+#define PRODOS_T_CFG    0x5A    /* Configuration                */
+#define PRODOS_T_ANM    0x5B    /* Animation                    */
+#define PRODOS_T_MUM    0x5C    /* Multimedia                   */
+#define PRODOS_T_ENT    0x5D    /* Entertainment                */
+#define PRODOS_T_DVU    0x5E    /* Development utility          */
+
+/* ProDOS PC Transporter file types */
+#define PRODOS_T_PRE    0x60    /* PC pre-boot                  */
+#define PRODOS_T_BIO    0x6B    /* PC BIOS                      */
+#define PRODOS_T_NCF    0x66    /* ProDOS File Nav command file */
+#define PRODOS_T_DVR    0x6D    /* PC driver                    */
+#define PRODOS_T_PRE2   0x6E    /* PC pre-boot                  */
+#define PRODOS_T_HDV    0x6F    /* PC hard disk image           */
+
+/* ProDOS Kreative Software file types */
+#define PRODOS_T_SN2    0x70    /* Sabine's Notebook 2.0        */
+#define PRODOS_T_KMT    0x71
+#define PRODOS_T_DSR    0x72
+#define PRODOS_T_BAN    0x73
+#define PRODOS_T_CG7    0x74
+#define PRODOS_T_TNJ    0x75
+#define PRODOS_T_SA7    0x76
+#define PRODOS_T_KES    0x77
+#define PRODOS_T_JAP    0x78
+#define PRODOS_T_CSL    0x79
+#define PRODOS_T_TME    0x7A
+#define PRODOS_T_TLB    0x7B
+#define PRODOS_T_MR7    0x7C
+#define PRODOS_T_MLR    0x7D    /* Mika City                    */
+#define PRODOS_T_MMM    0x7E
+#define PRODOS_T_JCP    0x7F
+
+/* ProDOS GEOS file types */
+#define PRODOS_T_GES    0x80    /* GEOS system file             */
+#define PRODOS_T_GEA    0x81    /* GEOS desk accessory          */
+#define PRODOS_T_GEO    0x82    /* GEOS application             */
+#define PRODOS_T_GED    0x83    /* GEOS document                */
+#define PRODOS_T_GEF    0x84    /* GEOS font                    */
+#define PRODOS_T_GEP    0x85    /* GEOS printer driver          */
+#define PRODOS_T_GEI    0x86    /* GEOS input driver            */
+#define PRODOS_T_GEX    0x87    /* GEOS auxiliary driver        */
+#define PRODOS_T_GEV    0x89    /* GEOS swap file               */
+#define PRODOS_T_GEC    0x8B    /* GEOS clock driver            */
+#define PRODOS_T_GEK    0x8C    /* GEOS interface card driver   */
+#define PRODOS_T_GEW    0x8D    /* GEOS formatting data         */
+
+/* ProDOS Apple IIgs BASIC file types */
+#define PRODOS_T_WP     0xA0    /* WordPerfect                  */
+#define PRODOS_T_GSB    0xAB    /* Apple IIgs BASIC program     */
+#define PRODOS_T_TDF    0xAB    /* Apple IIgs BASIC TDF         */
+#define PRODOS_T_BDF    0xAB    /* Apple IIgs BASIC data        */
+
+/* ProDOS Apple IIgs system file types */
+#define PRODOS_T_SRC    0xB0    /* Apple IIgs source code       */
+#define PRODOS_T_OBJ    0xB1    /* Apple IIgs object code       */
+#define PRODOS_T_LIB    0xB2    /* Apple IIgs library           */
+#define PRODOS_T_S16    0xB3    /* Apple IIgs application pgm   */
+#define PRODOS_T_RTL    0xB4    /* Apple IIgs runtime library   */
+#define PRODOS_T_EXE    0xB5    /* Apple IIgs shell script      */
+#define PRODOS_T_PIF    0xB6    /* Apple IIgs permanent init    */
+#define PRODOS_T_TIF    0xB7    /* Apple IIgs temporary init    */
+#define PRODOS_T_NDA    0xB8    /* Apple IIgs new desk accesry  */
+#define PRODOS_T_CDA    0xB9    /* Apple IIgs classic desk aces */
+#define PRODOS_T_TOL    0xBA    /* Apple IIgs tool              */
+#define PRODOS_T_DRV    0xBB    /* Apple IIgs device driver     */
+#define PRODOS_T_LDF    0xBC    /* Apple IIgs generic load file */
+#define PRODOS_T_FST    0xBD    /* Apple IIgs file sys translat */
+#define PRODOS_T_DOC    0xBF    /* Apple IIgs document          */
+
+/* ProDOS graphics file types */
+#define PRODOS_T_PNT    0xC0    /* Apple IIgs packed sup hi-res */
+#define PRODOS_T_PIC    0xC1    /* Apple IIgs super hi-res      */
+#define PRODOS_T_ANI    0xC2    /* PaintWorks animation         */
+#define PRODOS_T_PAL    0xC3    /* PaintWorks palette           */
+#define PRODOS_T_OOG    0xC5    /* Object-oriented graphics     */
+#define PRODOS_T_SCR    0xC6    /* Script                       */
+#define PRODOS_T_CDV    0xC7    /* Apple IIgs control panel     */
+#define PRODOS_T_FON    0xC8    /* Apple IIgs font              */
+#define PRODOS_T_FND    0xC9    /* Apple IIgs Finder data       */
+#define PRODOS_T_ICN    0xCA    /* Apple IIgs icon              */
+
+/* ProDOS audio file types */
+#define PRODOS_T_MUS    0xD5    /* Music                        */
+#define PRODOS_T_INS    0xD6    /* Instrument                   */
+#define PRODOS_T_MID    0xD7    /* MIDI                         */
+#define PRODOS_T_SND    0xD8    /* Apple IIgs audio             */
+#define PRODOS_T_DBM    0xDB    /* DB master document           */
+
+/* ProDOS miscellaneous file types */
+#define PRODOS_T_LBR    0xE0    /* Archive                      */
+#define PRODOS_T_ATK    0xE2    /* AppleTalk data               */
+#define PRODOS_T_R16    0xEE    /* EDASM 816 relocatable code   */
+#define PRODOS_T_PAR    0xEF    /* Pascal area                  */
+
+/* ProDOS system file types */
+#define PRODOS_T_CMD    0xF0    /* ProDOS command file          */
+#define PRODOS_T_OVL    0xF1    /* User defined 1               */
+#define PRODOS_T_UD2    0xF2    /* User defined 2               */
+#define PRODOS_T_UD3    0xF3    /* User defined 3               */
+#define PRODOS_T_UD4    0xF4    /* User defined 4               */
+#define PRODOS_T_BAT    0xF5    /* User defined 5               */
+#define PRODOS_T_UD6    0xF6    /* User defined 6               */
+#define PRODOS_T_UD7    0xF7    /* User defined 7               */
+#define PRODOS_T_PRG    0xF8    /* User defined 8               */
+#define PRODOS_T_P16    0xF9    /* ProDOS-16 system file        */
+#define PRODOS_T_INT    0xFA    /* Integer BASIC program        */
+#define PRODOS_T_IVR    0xFB    /* Integer BASIC variables      */
+#define PRODOS_T_BAS    0xFC    /* Applesoft BASIC program      */
+#define PRODOS_T_VAR    0xFD    /* Applesoft BASIC variables    */
+#define PRODOS_T_REL    0xFE    /* EDASM relocatable code       */
+#define PRODOS_T_SYS    0xFF    /* ProDOS-8 system file         */
+
+/* The auxiliary type of a text file specifies its record length.
+** A record length of 0 indicates a sequential text file, which is
+** equivalent to text files of other operating systems like MacOS
+** or Windows, except that lines are delimited by carriage returns
+** only. An auxiliary type value greater than 0 for a text file,
+** which is the record length, indicates a random access text file
+** with fixed-length lines.
+*/
+#define PRODOS_AUX_T_TXT_SEQ            0x0000  /* Sequential text          */
+
+/* 8IC auxiliary types */
+#define PRODOS_AUX_T_8IC_APEX_PGM       0x8003  /* Apex program             */
+
+/* GWP auxiliary types */
+#define PRODOS_AUX_T_GWP_TEACH          0x5445  /* Teach                    */
+#define PRODOS_AUX_T_GWP_DELUXEWRITE    0x8001  /* DeluxeWrite              */
+#define PRODOS_AUX_T_GWP_APPLEWORKS_GS  0x8010  /* AppleWorks GS            */
+
+/* GSS auxiliary types */
+#define PRODOS_AUX_T_GSS_APPLEWORKS_GS  0x8010  /* AppleWorks GS            */
+
+/* GDB auxiliary types */
+#define PRODOS_AUX_T_GDB_APPLEWORKS_GS  0x8010  /* AppleWorks GS DB         */
+#define PRODOS_AUX_T_GDB_AWGS_TMPL      0x8011  /* AWGS template            */
+#define PRODOS_AUX_T_GDB_GSAS           0x8013
+
+/* DRW auxiliary types */
+#define PRODOS_AUX_T_DRW_OO_GRAPHICS    0x8013  /* AWGS O-O graphics        */
+
+/* GDP auxiliary types */
+#define PRODOS_AUX_T_GDP_GRAPHICWRITER  0x8002  /* A2gs GraphicWriter       */
+#define PRODOS_AUX_T_GDP_APPLEWORKS_GS  0x8010  /* A2gs AWGS                */
+
+/* HMD auxiliary types */
+#define PRODOS_AUX_T_HMD_HYPERCARD_GS   0x0001  /* HyperCard GS             */
+#define PRODOS_AUX_T_HMD_TUTOR_TECH     0x8001  /* Tutor-Tech               */
+#define PRODOS_AUX_T_HMD_HYPERSTUDIO    0x8002  /* HyperStudio              */
+#define PRODOS_AUX_T_HMD_NEXUS          0x8003  /* Nexus                    */
+
+/* COM auxiliary types */
+#define PRODOS_AUX_T_COM_APPLEWORKS_GS  0x8003  /* AppleWorks GS            */
+
+/* MLR auxiliary types */
+#define PRODOS_AUX_T_MLR_SCRIPT         0x005C  /* Mika City script         */
+#define PRODOS_AUX_T_MLR_COLOR_TABLE    0xC7AB  /* Mika City color table    */
+#define PRODOS_AUX_T_MLR_CHARACTER_DEF  0xCDEF  /* Mika City character def  */
+
+/* LDF auxiliary types */
+#define PRODOS_AUX_T_LDF_NIFTY_LIST_MOD 0x4001  /* Nifty list module        */
+#define PRODOS_AUX_T_LDF_SUPER_INFO_MOD 0x4002  /* Super info module        */
+#define PRODOS_AUX_T_LDF_TWILIGHT_MOD   0x4004  /* Twilight module          */
+#define PRODOS_AUX_T_LDF_MARINETTI_LLM  0x4004  /* Marinetti link layer mod */
+
+/* PNT auxiliary types */
+#define PRODOS_AUX_T_PNT_PK_SUPER_HIRES 0x0001  /* Packed super hi-res      */
+#define PRODOS_AUX_T_PNT_APPLE_PREF     0x0002  /* Apple preferred format   */
+#define PRODOS_AUX_T_PNT_PK_QUICKDRAWII 0x0003  /* Packed QuickDraw II      */
+
+/* PIC auxiliary types */
+#define PRODOS_AUX_T_PIC_QUICKDRAW      0x0001  /* QuickDraw image          */
+#define PRODOS_AUX_T_PIC_SHIRES_3200    0x0002  /* Super hi-res 3200        */
+
+/* FON auxiliary types */
+#define PRODOS_AUX_T_FON_QUICKDRAW_BIT  0x0000  /* QuickDraw bitmap font    */
+#define PRODOS_AUX_T_FON_POINTLESS_TT   0x0001  /* Pointless TrueType font  */
+
+/* SND auxiliary types */
+#define PRODOS_AUX_T_SND_AIFF           0x0000  /* AIFF                     */
+#define PRODOS_AUX_T_SND_AIFF_C         0x0001  /* AIFF-C                   */
+#define PRODOS_AUX_T_SND_ASIF_INSTR     0x0002  /* ASIF instrument          */
+#define PRODOS_AUX_T_SND_SOUND_RSRC     0x0003  /* Sound resource           */
+#define PRODOS_AUX_T_SND_MIDI_SYNTH_WAV 0x0004  /* MIDI synth wave          */
+#define PRODOS_AUX_T_SND_HYPERSTUDIO    0x8001  /* HyperStudio sound        */
+
+/* LBR auxiliary types */
+#define PRODOS_AUX_T_LBR_ALU            0x0000  /* ALU                      */
+#define PRODOS_AUX_T_LBR_APPLE_SINGLE   0x0001  /* AppleSingle              */
+#define PRODOS_AUX_T_LBR_APPLEDBL_HDR   0x0002  /* AppleDouble header       */
+#define PRODOS_AUX_T_LBR_APPLEDBL_DATA  0x0003  /* AppleDouble data         */
+#define PRODOS_AUX_T_LBR_BINARY_II      0x8000  /* Binary II                */
+#define PRODOS_AUX_T_LBR_APPLELINK_ACU  0x8001  /* AppleLink ACU            */
+#define PRODOS_AUX_T_LBR_SHRINKIT       0x8002  /* ShrinkIt                 */
+
+/* LBR auxiliary types */
+#define PRODOS_AUX_T_ATK_EASYMNT_ALIAS  0x0000  /* EasyMount alias          */
+
+/* BAS auxiliary types */
+#define PRODOS_AUX_T_BAS_PGM_LOAD_ADDR  0x0801  /* Applesoft pgm load addr  */
+
+
+
+/*****************************************************************************/
+/*                                 Variables                                 */
+/*****************************************************************************/
+
+
+
+/* The file stream implementation and the POSIX I/O functions will use the
+** following variables to determine the file type and auxiliary type to use.
+** This applies specifically to the fopen and open functions.
+*/
+extern unsigned char _filetype;  /* Default: PRODOS_T_BIN */
+extern unsigned int _auxtype;    /* Default: 0            */
+
+/* End of apple2_filetype.h */
+#endif
index fa99fca20d719e1676d725349b73ed20437c3635..bf1af7d7bb0c1327193fab2a73ce2608cb3a73fb 100644 (file)
 #define TGI_COLOR_LIGHTBLUE     COLOR_LIGHTBLUE
 #define TGI_COLOR_GRAY3         COLOR_GRAY3
 
+/* Masks for joy_read */
+#define JOY_UP_MASK     0x01
+#define JOY_DOWN_MASK   0x02
+#define JOY_LEFT_MASK   0x04
+#define JOY_RIGHT_MASK  0x08
+#define JOY_BTN_1_MASK  0x10
+
+#define JOY_FIRE_MASK   JOY_BTN_1_MASK
+#define JOY_FIRE(v)     ((v) & JOY_FIRE_MASK)
+
 /* color register functions */
 extern void __fastcall__ _setcolor     (unsigned char color_reg, unsigned char hue, unsigned char luminace);
 extern void __fastcall__ _setcolor_low (unsigned char color_reg, unsigned char color_value);
@@ -346,4 +356,4 @@ struct __iocb {
 #define IOCB_FORMAT      0xFE  /* format */
 
 /* End of atari.h */
-#endif /* #ifndef _ATARI_H */
+#endif
index 4bd5bc0fd7421fa0031e18219e7691f094d16043..12c2bb349a570c1b15fb3fb2b8b0261fedf065a6 100644 (file)
@@ -87,6 +87,13 @@ extern void atr5200std_joy[];        /* referred to by joy_static_stddrv[] */
 #define COLOR_LIGHTBLUE         _gtia_mkcolor(HUE_BLUE,6)
 #define COLOR_GRAY3             _gtia_mkcolor(HUE_GREY,5)
 
+/* Masks for joy_read */
+#define JOY_UP_MASK     0x01
+#define JOY_DOWN_MASK   0x02
+#define JOY_LEFT_MASK   0x04
+#define JOY_RIGHT_MASK  0x08
+#define JOY_BTN_1_MASK  0x10
+
 /* get_tv return values */
 #define AT_NTSC     0
 #define AT_PAL      1
@@ -104,4 +111,4 @@ extern void atr5200std_joy[];        /* referred to by joy_static_stddrv[] */
 #define ANTIC (*(struct __antic*)0xD400)
 
 /* End of atari5200.h */
-#endif /* #ifndef _ATARI5200_H */
+#endif
index 72388c9748e2c948a431bcb141d3e221b2cd7fef..c642f9e2a6469bc40406ef13c7baaa6f259ab3c8 100644 (file)
 
 
 
+/* Masks for joy_read */
+#define JOY_UP_MASK     0x10
+#define JOY_DOWN_MASK   0x08
+#define JOY_LEFT_MASK   0x01
+#define JOY_RIGHT_MASK  0x02
+#define JOY_BTN_1_MASK  0x20
+
+
+
 /* No support for dynamically loadable drivers */
 #define DYN_DRV         0
 
index 565fbc9ce71c42e63a7a01ee0f57837a9f64cc49..356140d41b9c7362abfed850f20d638b4c254e1b 100644 (file)
 #define TGI_COLOR_LIGHTBLUE     COLOR_LIGHTBLUE
 #define TGI_COLOR_GRAY3         COLOR_GRAY3
 
+/* Masks for joy_read */
+#define JOY_UP_MASK             0x01
+#define JOY_DOWN_MASK           0x02
+#define JOY_LEFT_MASK           0x04
+#define JOY_RIGHT_MASK          0x08
+#define JOY_BTN_1_MASK          0x10
+
 /* Video mode defines */
 #define VIDEOMODE_40x25         0x00
 #define VIDEOMODE_80x25         0x80
index adf3840b93a0a9c0f35dc6b240d991b6fd129839..eb10600d6b6cbfd8a7cb152f37a243771aa78509 100644 (file)
 #define TGI_COLOR_LIGHTBLUE     COLOR_LIGHTBLUE
 #define TGI_COLOR_GRAY3         COLOR_GRAY3
 
+/* Masks for joy_read */
+#define JOY_UP_MASK             0x01
+#define JOY_DOWN_MASK           0x02
+#define JOY_LEFT_MASK           0x04
+#define JOY_RIGHT_MASK          0x08
+#define JOY_BTN_1_MASK          0x10
+
 /* Define hardware */
 #include <_vic2.h>
 #define VIC     (*(struct __vic2*)0xD000)
index 241d70a6e7b82fc481dbc92a4600173100eddf55..a4b2324069475bc8d694ef5d7a8c014f3489d031 100644 (file)
 
 
 
+#define JOY_FIRE_MASK   JOY_BTN_1_MASK
+#define JOY_FIRE(v)     ((v) & JOY_FIRE_MASK)
+
+
+
 /*****************************************************************************/
 /*                                 Variables                                 */
 /*****************************************************************************/
@@ -153,7 +158,17 @@ struct cbm_dirent {
 unsigned char get_tv (void);
 /* Return the video mode the machine is using. */
 
+#define KBREPEAT_CURSOR 0x00
+#define KBREPEAT_NONE   0x40
+#define KBREPEAT_ALL    0x80
 
+unsigned char __fastcall__ kbrepeat (unsigned char mode);
+/* Changes which keys have automatic repeat. */
+
+#if !defined(__CBM610__) && !defined(__PET__)
+void waitvsync (void);
+/* Wait for the start of the next frame */
+#endif
 
 /*****************************************************************************/
 /*                           CBM kernal functions                            */
index ff7468d307253668c329cb3f4b86fc3d5908c9a4..46fa64050c3893dcd051b48537e3ece3c9d7e731 100644 (file)
 #define COLOR_LIGHTBLUE         (BCOLOR_LIGHTBLUE | CATTR_LUMA7)
 #define COLOR_GRAY3             (BCOLOR_WHITE | CATTR_LUMA5)
 
+
+
+/* Masks for joy_read */
+#define JOY_UP_MASK             0x01
+#define JOY_DOWN_MASK           0x02
+#define JOY_LEFT_MASK           0x04
+#define JOY_RIGHT_MASK          0x08
+#define JOY_BTN_1_MASK          0x80
+
+
+
 /* Define hardware */
 #include <_ted.h>
 #define TED             (*(struct __ted*)0xFF00)
index 25ea0754039287a1f4cb5b2c4334cba0c20c7fc1..3d6ccd209e7b5ce6ace65331b0f937c1b67a54c9 100644 (file)
 #define COLOR_LIGHTBLUE         0x0E
 #define COLOR_GRAY3             0x0F
 
+/* Masks for joy_read */
+#define JOY_UP_MASK             0x01
+#define JOY_DOWN_MASK           0x02
+#define JOY_LEFT_MASK           0x04
+#define JOY_RIGHT_MASK          0x08
+#define JOY_BTN_1_MASK          0x10
+
 /* Define hardware */
 #include <_vic2.h>
 #define VIC     (*(struct __vic2*)0xD800)
index 9eb68e565b05aa8ea1142175cc55a6cd0dd12119..baf55dd082583820d31b8d9941dc2b17b46001ce 100644 (file)
 #  include <apple2enh.h>
 #elif defined(__APPLE2__)
 #  include <apple2.h>
+#elif defined(__ATARI5200__)
+#  include <atari5200.h>
 #elif defined(__ATARI__)
 #  include <atari.h>
 #elif defined(__ATMOS__)
 #  include <atmos.h>
 #elif defined(__CBM__)
 #  include <cbm.h>
+#elif defined(__CREATIVISION__)
+#  include <creativision.h>
 #elif defined(__GAMATE__)
 #  include <gamate.h>
 #elif defined(__GEOS__)
@@ -225,6 +229,3 @@ void __fastcall__ cputhex16 (unsigned val);
 
 /* End of conio.h */
 #endif
-
-
-
index 5cc99b7affb04ce8fd5f92ca448ee26f29a4e3f0..a97109029279a41928736af21ca6709ccec3c5f2 100644 (file)
 #define CH_LLCORNER 37
 #define CH_LRCORNER 38
 
+/* Masks for joy_read */
+#define JOY_UP_MASK     0x10
+#define JOY_DOWN_MASK   0x04
+#define JOY_LEFT_MASK   0x20
+#define JOY_RIGHT_MASK  0x08
+#define JOY_BTN_1_MASK  0x01
+#define JOY_BTN_2_MASK  0x02
+
 /* no support for dynamically loadable drivers */
 #define DYN_DRV 0
 
index b440bfb70f6fbcc72f2aae3fe86fb8e4949b4c73..17cbafe9fd70d3558548eedd1a0be3b5f4324193 100644 (file)
@@ -89,9 +89,9 @@ unsigned char __fastcall__ toascii (unsigned char c);
 ** #undef'ing the macroes.
 ** Please note that the following macroes do NOT handle EOF correctly, as
 ** stated in the manual. If you need correct behaviour for EOF, don't
-** use -Os, or #undefine the following macroes.
+** use --eagerly-inline-funcs, or #undefine the following macroes.
 */
-#ifdef __OPT_s__
+#ifdef __EAGERLY_INLINE_FUNCS__
 
 #define isalnum(c)  (__AX__ = (c),                      \
                     __asm__ ("tay"),                    \
index e5df803216164be83aee5608462080a5625c3dfe..ffc6e131a9db1ea1472fe6969c260b009ba2954f 100644 (file)
@@ -52,6 +52,7 @@ typedef struct {
     /* Driver header */
     char                id[3];          /* Contains 0x65, 0x6d, 0x64 ("emd") */
     unsigned char       version;        /* Interface version */
+    void*               libreference;   /* Library reference */
 
     /* Jump vectors. Note that these are not C callable */
     void*               install;        /* INSTALL routine */
@@ -74,6 +75,3 @@ extern em_drv_header*   em_drv;         /* Pointer to driver */
 
 /* End of em-kernel.h */
 #endif
-
-
-
index 82bca08b1c5929efdf1278eaf9bff20f5ff9b174..0af21623d102664028703034e82831cf62ca96a9 100644 (file)
  bit 3:
 */
 
-#define JOY_DATA        0x4400
-
-#define JOY_DATA_UP     0x01
-#define JOY_DATA_DOWN   0x02
-#define JOY_DATA_LEFT   0x04
-#define JOY_DATA_RIGHT  0x08
-#define JOY_DATA_FIRE_A 0x10
-#define JOY_DATA_FIRE_B 0x20
-#define JOY_DATA_START  0x40
-#define JOY_DATA_SELECT 0x80
-
 /* LCD
 
     resolution 160x152 in 4 greys/greens
 /* No support for dynamically loadable drivers */
 #define DYN_DRV         0
 
+/* Masks for joy_read */
+#define JOY_UP_MASK     0x01
+#define JOY_DOWN_MASK   0x02
+#define JOY_LEFT_MASK   0x04
+#define JOY_RIGHT_MASK  0x08
+#define JOY_BTN_1_MASK  0x10
+#define JOY_BTN_2_MASK  0x20
+#define JOY_BTN_3_MASK  0x40
+#define JOY_BTN_4_MASK  0x80
+
+#define JOY_BTN_A_MASK  JOY_BTN_1_MASK
+#define JOY_BTN_B_MASk  JOY_BTN_2_MASK
+#define JOY_START_MASK  JOY_BTN_3_MASK
+#define JOY_SELECT_MASK JOY_BTN_4_MASK
+
+#define JOY_BTN_A(v)    ((v) & JOY_BTN_A_MASK)
+#define JOY_BTN_B(v)    ((v) & JOY_BTN_B_MASK)
+#define JOY_START(v)    ((v) & JOY_START_MASK)
+#define JOY_SELECT(v)   ((v) & JOY_SELECT_MASK)
+
 /* The addresses of the static drivers */
 extern void gamate_stdjoy_joy[];   /* Referred to by joy_static_stddrv[] */
 
-#define JOY_FIRE_B      5
-#define JOY_START       6
-#define JOY_SELECT      7
-
-void waitvblank (void);
-/* Wait for the vertical blanking */
+void waitvsync (void);
+/* Wait for start of next frame */
 
 /* NOTE: all Gamate are "NTSC" */
 #define get_tv()        TV_NTSC
index 65b85cd595631199136b967ae8913f6f0c8fc8eb..ae356d679923655ca823cf7501816d47eb44b5a1 100644 (file)
 #define TGI_COLOR_LIGHTBLUE     COLOR_LIGHTBLUE
 #define TGI_COLOR_GRAY3         COLOR_GRAY3
 
+#define JOY_UP_MASK             0x01
+#define JOY_DOWN_MASK           0x02
+#define JOY_LEFT_MASK           0x04
+#define JOY_RIGHT_MASK          0x08
+#define JOY_BTN_1_MASK          0x10
+
 
 /* End of geos.h */
 #endif
index 710d9b5a6b65852ae65101a72647a0888388f763..26f339fe4f392227accca399d7f35ee8d424a881 100644 (file)
 #define JOY_ERR_NO_DEVICE       4       /* Device (hardware) not found */
 
 /* Argument for the joy_read function */
-#define JOY_1           0
-#define JOY_2           1
-
-/* The following codes are *indices* into the joy_masks array */
-#define JOY_UP          0
-#define JOY_DOWN        1
-#define JOY_LEFT        2
-#define JOY_RIGHT       3
-#define JOY_FIRE        4
-#define JOY_FIRE2       5               /* Second fire button if available */
-
-/* Array of masks used to check the return value of joy_read for a state */
-extern const unsigned char joy_masks[8];
+#define JOY_1                   0
+#define JOY_2                   1
 
 /* Macros that evaluate the return code of joy_read */
-#define JOY_BTN_UP(v)           ((v) & joy_masks[JOY_UP])
-#define JOY_BTN_DOWN(v)         ((v) & joy_masks[JOY_DOWN])
-#define JOY_BTN_LEFT(v)         ((v) & joy_masks[JOY_LEFT])
-#define JOY_BTN_RIGHT(v)        ((v) & joy_masks[JOY_RIGHT])
-#define JOY_BTN_FIRE(v)         ((v) & joy_masks[JOY_FIRE])
-#define JOY_BTN_FIRE2(v)        ((v) & joy_masks[JOY_FIRE2])
+#define JOY_UP(v)               ((v) & JOY_UP_MASK)
+#define JOY_DOWN(v)             ((v) & JOY_DOWN_MASK)
+#define JOY_LEFT(v)             ((v) & JOY_LEFT_MASK)
+#define JOY_RIGHT(v)            ((v) & JOY_RIGHT_MASK)
+#define JOY_BTN_1(v)            ((v) & JOY_BTN_1_MASK)      /* Universally available */
+#define JOY_BTN_2(v)            ((v) & JOY_BTN_2_MASK)      /* Second button if available */
+#define JOY_BTN_3(v)            ((v) & JOY_BTN_3_MASK)      /* Third button if available  */
+#define JOY_BTN_4(v)            ((v) & JOY_BTN_4_MASK)      /* Fourth button if available */
 
 /* The name of the standard joystick driver for a platform */
 extern const char joy_stddrv[];
index bb571de3d9b7ecdc06c1b1af6fdb23ad84f0c958..e984291f7b37532c474b52030920d7057d4add96 100644 (file)
@@ -52,9 +52,7 @@ typedef struct {
     /* Driver header */
     char                id[3];          /* Contains 0x6a, 0x6f, 0x79 ("joy") */
     unsigned char       version;        /* Interface version */
-
-    /* Bitmasks for the joystick states. See joystick.h for indices */
-    unsigned char       masks[8];
+    void*               libreference;   /* Library reference */
 
     /* Jump vectors. Note that these are not C callable */
     void*               install;        /* INSTALL routine */
@@ -85,6 +83,3 @@ void joy_clear_ptr (void);
 
 /* End of joy-kernel.h */
 #endif
-
-
-
index 72f3d5bfd6a4221fc2b98e69986544e3d8a9e73c..3629f322e9329532b5152f9964181cda44da9c44 100644 (file)
 #define TGI_COLOR_LIGHTBLUE     COLOR_LIGHTBLUE
 #define TGI_COLOR_WHITE         COLOR_WHITE
 
+/* Masks for joy_read */
+#define JOY_UP_MASK             0x80
+#define JOY_DOWN_MASK           0x40
+#define JOY_LEFT_MASK           0x20
+#define JOY_RIGHT_MASK          0x10
+#define JOY_BTN_1_MASK          0x01
+#define JOY_BTN_2_MASK          0x02
+
+#define JOY_BTN_A_MASK          JOY_BTN_1_MASK
+#define JOY_BTN_B_MASK          JOY_BTN_2_MASK
+
+#define JOY_BTN_A(v)            ((v) & JOY_BTN_A_MASK)
+#define JOY_BTN_B(v)            ((v) & JOY_BTN_B_MASK)
+
 /* No support for dynamically loadable drivers */
 #define DYN_DRV 0
 
diff --git a/include/lz4.h b/include/lz4.h
new file mode 100644 (file)
index 0000000..fd11c3e
--- /dev/null
@@ -0,0 +1,43 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                                  lz4.h                                    */
+/*                                                                           */
+/*              Decompression routine for the 'lz4' format                   */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2017 Mega Cat Studios                                                 */
+/*                                                                           */
+/* This software is provided 'as-is', without any expressed or implied       */
+/* warranty.  In no event will the authors be held liable for any damages    */
+/* arising from the use of this software.                                    */
+/*                                                                           */
+/* Permission is granted to anyone to use this software for any purpose,     */
+/* including commercial applications, and to alter it and redistribute it    */
+/* freely, subject to the following restrictions:                            */
+/*                                                                           */
+/* 1. The origin of this software must not be misrepresented; you must not   */
+/*    claim that you wrote the original software. If you use this software   */
+/*    in a product, an acknowledgment in the product documentation would be  */
+/*    appreciated but is not required.                                       */
+/* 2. Altered source versions must be plainly marked as such, and must not   */
+/*    be misrepresented as being the original software.                      */
+/* 3. This notice may not be removed or altered from any source              */
+/*    distribution.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+
+
+#ifndef _LZ4_H
+#define _LZ4_H
+
+void __fastcall__ decompress_lz4 (const unsigned char* src, unsigned char* const dst,
+                                  const unsigned short uncompressed_size);
+/* Decompresses the source buffer into the destination buffer.
+** The size of the decompressed data must be known in advance, LZ4
+** does not include any terminator in-stream.
+*/
+
+/* end of lz4.h */
+#endif
index a472a0f3c9cd587369163ae43a27cf54ca40ce1e..217a90779ac716b6c644b6f8105d4216b76e896d 100644 (file)
 #define COLOR_LIGHTBLUE         0x0E
 #define COLOR_GRAY3             0x0F
 
+/* Masks for joy_read */
+#define JOY_UP_MASK     0x10
+#define JOY_DOWN_MASK   0x20
+#define JOY_LEFT_MASK   0x40
+#define JOY_RIGHT_MASK  0x80
+#define JOY_BTN_1_MASK  0x01
+#define JOY_BTN_2_MASK  0x02
+#define JOY_BTN_3_MASK  0x04
+#define JOY_BTN_4_MASK  0x08
+
+#define JOY_BTN_A_MASK  JOY_BTN_1_MASK
+#define JOY_BTN_B_MASK  JOY_BTN_2_MASK
+#define JOY_SELECT_MASK JOY_BTN_3_MASK
+#define JOY_START_MASK  JOY_BTN_4_MASK
+
+#define JOY_BTN_A(v)    ((v) & JOY_BTN_A_MASK)
+#define JOY_BTN_B(v)    ((v) & JOY_BTN_B_MASK)
+#define JOY_SELECT(v)   ((v) & JOY_SELECT_MASK)
+#define JOY_START(v)    ((v) & JOY_START_MASK)
+
 /* Return codes of get_tv */
 #define TV_NTSC         0
 #define TV_PAL          1
 /* No support for dynamically loadable drivers */
 #define DYN_DRV         0
 
-/* The joystick keys - all keys are supported */
-#define KEY_A           0x01
-#define KEY_B           0x02
-#define KEY_SELECT      0x04
-#define KEY_START       0x08
-#define KEY_UP          0x10
-#define KEY_DOWN        0x20
-#define KEY_LEFT        0x40
-#define KEY_RIGHT       0x80
-
 /* Define hardware */
 
 /* Picture Processing Unit */
@@ -163,8 +173,8 @@ extern void nes_64_56_2_tgi[];      /* Referred to by tgi_static_stddrv[] */
 
 
 
-void waitvblank (void);
-/* Wait for the vertical blanking */
+void waitvsync (void);
+/* Wait for start of the next frame */
 
 unsigned char get_tv (void);
 /* Return the video mode the machine is using. */
index 57fe0cd240ad343bd353f8baa5d14f11718c47c8..d6ab5fee179327c57b1a4dab5f9ed99a3863d05b 100644 (file)
@@ -1,47 +1,47 @@
-/*****************************************************************************/\r
-/*                                                                           */\r
-/*                                osic1p.h                                   */\r
-/*                                                                           */\r
-/*                Challenger 1P system specific definitions                  */\r
-/*                                                                           */\r
-/*                                                                           */\r
-/*                                                                           */\r
-/* (C) 2015 Stephan Muehlstrasser                                            */\r
-/*                                                                           */\r
-/*                                                                           */\r
-/* This software is provided 'as-is', without any expressed or implied       */\r
-/* warranty.  In no event will the authors be held liable for any damages    */\r
-/* arising from the use of this software.                                    */\r
-/*                                                                           */\r
-/* Permission is granted to anyone to use this software for any purpose,     */\r
-/* including commercial applications, and to alter it and redistribute it    */\r
-/* freely, subject to the following restrictions:                            */\r
-/*                                                                           */\r
-/* 1. The origin of this software must not be misrepresented; you must not   */\r
-/*    claim that you wrote the original software. If you use this software   */\r
-/*    in a product, an acknowledgment in the product documentation would be  */\r
-/*    appreciated but is not required.                                       */\r
-/* 2. Altered source versions must be plainly marked as such, and must not   */\r
-/*    be misrepresented as being the original software.                      */\r
-/* 3. This notice may not be removed or altered from any source              */\r
-/*    distribution.                                                          */\r
-/*                                                                           */\r
-/*****************************************************************************/\r
-\r
-#ifndef _OSIC1P_H\r
-#define _OSIC1P_H\r
-\r
-/* Check for errors */\r
-#if !defined(__OSIC1P__)\r
-#  error "This module may only be used when compiling for the Challenger 1P!"\r
-#endif\r
-\r
-/* The following #defines will cause the matching functions calls in conio.h\r
-** to be overlaid by macros with the same names, saving the function call\r
-** overhead.\r
-*/\r
-#define _textcolor(color)       COLOR_WHITE\r
-#define _bgcolor(color)         COLOR_BLACK\r
-#define _bordercolor(color)     COLOR_BLACK\r
-\r
-#endif\r
+/*****************************************************************************/
+/*                                                                           */
+/*                                osic1p.h                                   */
+/*                                                                           */
+/*                Challenger 1P system specific definitions                  */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2015 Stephan Muehlstrasser                                            */
+/*                                                                           */
+/*                                                                           */
+/* This software is provided 'as-is', without any expressed or implied       */
+/* warranty.  In no event will the authors be held liable for any damages    */
+/* arising from the use of this software.                                    */
+/*                                                                           */
+/* Permission is granted to anyone to use this software for any purpose,     */
+/* including commercial applications, and to alter it and redistribute it    */
+/* freely, subject to the following restrictions:                            */
+/*                                                                           */
+/* 1. The origin of this software must not be misrepresented; you must not   */
+/*    claim that you wrote the original software. If you use this software   */
+/*    in a product, an acknowledgment in the product documentation would be  */
+/*    appreciated but is not required.                                       */
+/* 2. Altered source versions must be plainly marked as such, and must not   */
+/*    be misrepresented as being the original software.                      */
+/* 3. This notice may not be removed or altered from any source              */
+/*    distribution.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef _OSIC1P_H
+#define _OSIC1P_H
+
+/* Check for errors */
+#if !defined(__OSIC1P__)
+#  error "This module may only be used when compiling for the Challenger 1P!"
+#endif
+
+/* The following #defines will cause the matching functions calls in conio.h
+** to be overlaid by macros with the same names, saving the function call
+** overhead.
+*/
+#define _textcolor(color)       COLOR_WHITE
+#define _bgcolor(color)         COLOR_BLACK
+#define _bordercolor(color)     COLOR_BLACK
+
+#endif
index 7700654c805244cebaab132934c10ae8c57c6760..7744d0148f63a5095f94f298870e012c969fb82f 100644 (file)
 #define TV_PAL                  1
 #define TV_OTHER                2
 
+/* Masks for joy_read */
+#define JOY_UP_MASK             0x10
+#define JOY_DOWN_MASK           0x40
+#define JOY_LEFT_MASK           0x80
+#define JOY_RIGHT_MASK          0x20
+#define JOY_BTN_1_MASK          0x01
+#define JOY_BTN_2_MASK          0x02
+#define JOY_BTN_3_MASK          0x04
+#define JOY_BTN_4_MASK          0x08
+
+#define JOY_BTN_I_MASK          JOY_BTN_1_MASK
+#define JOY_BTN_II_MASK         JOY_BTN_2_MASK
+#define JOY_SELECT_MASK         JOY_BTN_3_MASK
+#define JOY_RUN_MASK            JOY_BTN_4_MASK
+
+#define JOY_BTN_I(v)            ((v) & JOY_BTN_I_MASK)
+#define JOY_BTN_II(v)           ((v) & JOY_BTN_II_MASK)
+#define JOY_SELECT(v)           ((v) & JOY_SELECT_MASK)
+#define JOY_RUN(v)              ((v) & JOY_RUN_MASK)
+
 /* No support for dynamically loadable drivers */
-#define DYN_DRV         0
+#define DYN_DRV                 0
 
 /* The addresses of the static drivers */
 extern void pce_stdjoy_joy[];   /* Referred to by joy_static_stddrv[] */
 
-#define JOY_FIRE_B              5
-#define JOY_SELECT              6
-#define JOY_RUN                 7
-
-void waitvblank (void);
-/* Wait for the vertical blanking */
+void waitvsync (void);
+/* Wait for start of the next frame */
 
 /* NOTE: all PCE are NTSC */
 #define get_tv()                TV_NTSC
index 720e40a783bc6af3ab8761d86189fbcd31739873..e9659d52463911856c2023913e1997e41dd30623 100644 (file)
 #define COLOR_BLACK             0x00
 #define COLOR_WHITE             0x01
 
+/* Masks for joy_read */
+#define JOY_UP_MASK             0x01
+#define JOY_DOWN_MASK           0x02
+#define JOY_LEFT_MASK           0x04
+#define JOY_RIGHT_MASK          0x08
+#define JOY_BTN_1_MASK          0x10
+
 /* Define hardware */
 #include <_pia.h>
 #define PIA1    (*(struct __pia*)0xE810)
index c675de6d23cedea7eb2d4555d9843d10e6b676c6..c6ad9632d7368f0f02d2fe7267782aade83be940 100644 (file)
 
 
 
+/* Masks for joy_read */
+#define JOY_UP_MASK             0x01
+#define JOY_DOWN_MASK           0x02
+#define JOY_LEFT_MASK           0x04
+#define JOY_RIGHT_MASK          0x08
+#define JOY_BTN_1_MASK          0x10
+
+
+
 /* Define hardware */
 #include <_vic.h>
 #define VIC     (*(struct __vic*)0x9000)
index 8fa6a2bd12c7c035e545e7a04f7e79e0a3fd6bbb..8ced898004a4cc7364a2c2d0f839a0e0e0971e5c 100644 (file)
-/*****************************************************************************/\r
-/*                                                                           */\r
-/*                                  zlib.h                                   */\r
-/*                                                                           */\r
-/*              Decompression routines for the 'deflate' format              */\r
-/*                                                                           */\r
-/*                                                                           */\r
-/*                                                                           */\r
-/* (C) 2000-2015 Piotr Fusik <fox@scene.pl>                                  */\r
-/*                                                                           */\r
-/* This file is based on the zlib.h from 'zlib' general purpose compression  */\r
-/* library, version 1.1.3, (C) 1995-1998 Jean-loup Gailly and Mark Adler.    */\r
-/*                                                                           */\r
-/*  Jean-loup Gailly        Mark Adler                                       */\r
-/*  jloup@gzip.org          madler@alumni.caltech.edu                        */\r
-/*                                                                           */\r
-/* This software is provided 'as-is', without any expressed or implied       */\r
-/* warranty.  In no event will the authors be held liable for any damages    */\r
-/* arising from the use of this software.                                    */\r
-/*                                                                           */\r
-/* Permission is granted to anyone to use this software for any purpose,     */\r
-/* including commercial applications, and to alter it and redistribute it    */\r
-/* freely, subject to the following restrictions:                            */\r
-/*                                                                           */\r
-/* 1. The origin of this software must not be misrepresented; you must not   */\r
-/*    claim that you wrote the original software. If you use this software   */\r
-/*    in a product, an acknowledgment in the product documentation would be  */\r
-/*    appreciated but is not required.                                       */\r
-/* 2. Altered source versions must be plainly marked as such, and must not   */\r
-/*    be misrepresented as being the original software.                      */\r
-/* 3. This notice may not be removed or altered from any source              */\r
-/*    distribution.                                                          */\r
-/*                                                                           */\r
-/*****************************************************************************/\r
-\r
-\r
-\r
-#ifndef _ZLIB_H\r
-#define _ZLIB_H\r
-\r
-#define Z_OK         0\r
-#define Z_DATA_ERROR (-3)\r
-/* Return codes for uncompress() */\r
-\r
-#define Z_DEFLATED   8\r
-/* The deflate compression method (the only one supported) */\r
-\r
-#define Z_NULL       0\r
-\r
-\r
-unsigned __fastcall__ inflatemem (char* dest, const char* source);\r
-/*\r
-     Decompresses the source buffer into the destination buffer.\r
-   Returns the size of the uncompressed data (number of bytes written starting\r
-   from dest).\r
-\r
-     This function expects data in the DEFLATE format, described in RFC\r
-   (Request for Comments) 1951 in the file\r
-   ftp://ds.internic.net/rfc/rfc1951.txt.\r
-\r
-     This function does not exist in the original zlib. Its implementation\r
-   using original zlib might be following:\r
-\r
-   unsigned inflatemem (char* dest, const char* source)\r
-   {\r
-     z_stream stream;\r
-\r
-     stream.next_in = (Bytef*) source;\r
-     stream.avail_in = 65535;\r
-\r
-     stream.next_out = dest;\r
-     stream.avail_out = 65535;\r
-\r
-     stream.zalloc = (alloc_func) 0;\r
-     stream.zfree = (free_func) 0;\r
-\r
-     inflateInit2(&stream, -MAX_WBITS);\r
-     inflate(&stream, Z_FINISH);\r
-     inflateEnd(&stream);\r
-\r
-     return stream.total_out;\r
-   }\r
-*/\r
-\r
-\r
-int __fastcall__ uncompress (char* dest, unsigned* destLen,\r
-                             const char* source, unsigned sourceLen);\r
-/*\r
-   Original zlib description:\r
-\r
-     Decompresses the source buffer into the destination buffer.  sourceLen is\r
-   the byte length of the source buffer. Upon entry, destLen is the total\r
-   size of the destination buffer, which must be large enough to hold the\r
-   entire uncompressed data. (The size of the uncompressed data must have\r
-   been saved previously by the compressor and transmitted to the decompressor\r
-   by some mechanism outside the scope of this compression library.)\r
-   Upon exit, destLen is the actual size of the compressed buffer.\r
-     This function can be used to decompress a whole file at once if the\r
-   input file is mmap'ed.\r
-\r
-     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not\r
-   enough memory, Z_BUF_ERROR if there was not enough room in the output\r
-   buffer, or Z_DATA_ERROR if the input data was corrupted.\r
-\r
-   Implementation notes:\r
-\r
-     This function expects data in the ZLIB format, described in RFC 1950\r
-   in the file ftp://ds.internic.net/rfc/rfc1950.txt. The ZLIB format is\r
-   essentially the DEFLATE format plus a very small header and Adler-32\r
-   checksum.\r
-\r
-     Z_MEM_ERROR and Z_BUF_ERROR are never returned in this implementation.\r
-*/\r
-\r
-\r
-unsigned long __fastcall__ adler32 (unsigned long adler, const char* buf,\r
-                                    unsigned len);\r
-\r
-/*\r
-   Original zlib description:\r
-\r
-     Update a running Adler-32 checksum with the bytes buf[0..len-1] and\r
-   return the updated checksum. If buf is NULL, this function returns\r
-   the required initial value for the checksum.\r
-   An Adler-32 checksum is almost as reliable as a CRC32 but can be computed\r
-   much faster. Usage example:\r
-\r
-     unsigned long adler = adler32(0L, Z_NULL, 0);\r
-\r
-     while (read_buffer(buffer, length) != EOF) {\r
-       adler = adler32(adler, buffer, length);\r
-     }\r
-     if (adler != original_adler) error();\r
-\r
-   Implementation notes:\r
-\r
-     This function isn't actually much faster than crc32(), but it is smaller\r
-   and does not use any lookup tables.\r
-*/\r
-\r
-\r
-unsigned long __fastcall__ crc32 (unsigned long crc, const char* buf,\r
-                                  unsigned len);\r
-/*\r
-   Original zlib description:\r
-\r
-     Update a running crc with the bytes buf[0..len-1] and return the updated\r
-   crc. If buf is NULL, this function returns the required initial value\r
-   for the crc. Pre- and post-conditioning (one's complement) is performed\r
-   within this function so it shouldn't be done by the application.\r
-   Usage example:\r
-\r
-     unsigned long crc = crc32(0L, Z_NULL, 0);\r
-\r
-     while (read_buffer(buffer, length) != EOF) {\r
-       crc = crc32(crc, buffer, length);\r
-     }\r
-     if (crc != original_crc) error();\r
-\r
-   Implementation notes:\r
-\r
-     This function uses statically allocated 1 KB lookup table. The table is\r
-   initialised before it is used for the first time (that is, if buffer is\r
-   NULL or length is zero, then the lookup table isn't initialised).\r
-*/\r
-\r
-\r
-/* end of zlib.h */\r
-#endif\r
-\r
-\r
-\r
+/*****************************************************************************/
+/*                                                                           */
+/*                                  zlib.h                                   */
+/*                                                                           */
+/*              Decompression routines for the 'deflate' format              */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2000-2015 Piotr Fusik <fox@scene.pl>                                  */
+/*                                                                           */
+/* This file is based on the zlib.h from 'zlib' general purpose compression  */
+/* library, version 1.1.3, (C) 1995-1998 Jean-loup Gailly and Mark Adler.    */
+/*                                                                           */
+/*  Jean-loup Gailly        Mark Adler                                       */
+/*  jloup@gzip.org          madler@alumni.caltech.edu                        */
+/*                                                                           */
+/* This software is provided 'as-is', without any expressed or implied       */
+/* warranty.  In no event will the authors be held liable for any damages    */
+/* arising from the use of this software.                                    */
+/*                                                                           */
+/* Permission is granted to anyone to use this software for any purpose,     */
+/* including commercial applications, and to alter it and redistribute it    */
+/* freely, subject to the following restrictions:                            */
+/*                                                                           */
+/* 1. The origin of this software must not be misrepresented; you must not   */
+/*    claim that you wrote the original software. If you use this software   */
+/*    in a product, an acknowledgment in the product documentation would be  */
+/*    appreciated but is not required.                                       */
+/* 2. Altered source versions must be plainly marked as such, and must not   */
+/*    be misrepresented as being the original software.                      */
+/* 3. This notice may not be removed or altered from any source              */
+/*    distribution.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+
+
+#ifndef _ZLIB_H
+#define _ZLIB_H
+
+#define Z_OK         0
+#define Z_DATA_ERROR (-3)
+/* Return codes for uncompress() */
+
+#define Z_DEFLATED   8
+/* The deflate compression method (the only one supported) */
+
+#define Z_NULL       0
+
+
+unsigned __fastcall__ inflatemem (char* dest, const char* source);
+/*
+     Decompresses the source buffer into the destination buffer.
+   Returns the size of the uncompressed data (number of bytes written starting
+   from dest).
+
+     This function expects data in the DEFLATE format, described in RFC
+   (Request for Comments) 1951 in the file
+   ftp://ds.internic.net/rfc/rfc1951.txt.
+
+     This function does not exist in the original zlib. Its implementation
+   using original zlib might be following:
+
+   unsigned inflatemem (char* dest, const char* source)
+   {
+     z_stream stream;
+
+     stream.next_in = (Bytef*) source;
+     stream.avail_in = 65535;
+
+     stream.next_out = dest;
+     stream.avail_out = 65535;
+
+     stream.zalloc = (alloc_func) 0;
+     stream.zfree = (free_func) 0;
+
+     inflateInit2(&stream, -MAX_WBITS);
+     inflate(&stream, Z_FINISH);
+     inflateEnd(&stream);
+
+     return stream.total_out;
+   }
+*/
+
+
+int __fastcall__ uncompress (char* dest, unsigned* destLen,
+                             const char* source, unsigned sourceLen);
+/*
+   Original zlib description:
+
+     Decompresses the source buffer into the destination buffer.  sourceLen is
+   the byte length of the source buffer. Upon entry, destLen is the total
+   size of the destination buffer, which must be large enough to hold the
+   entire uncompressed data. (The size of the uncompressed data must have
+   been saved previously by the compressor and transmitted to the decompressor
+   by some mechanism outside the scope of this compression library.)
+   Upon exit, destLen is the actual size of the compressed buffer.
+     This function can be used to decompress a whole file at once if the
+   input file is mmap'ed.
+
+     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
+   enough memory, Z_BUF_ERROR if there was not enough room in the output
+   buffer, or Z_DATA_ERROR if the input data was corrupted.
+
+   Implementation notes:
+
+     This function expects data in the ZLIB format, described in RFC 1950
+   in the file ftp://ds.internic.net/rfc/rfc1950.txt. The ZLIB format is
+   essentially the DEFLATE format plus a very small header and Adler-32
+   checksum.
+
+     Z_MEM_ERROR and Z_BUF_ERROR are never returned in this implementation.
+*/
+
+
+unsigned long __fastcall__ adler32 (unsigned long adler, const char* buf,
+                                    unsigned len);
+
+/*
+   Original zlib description:
+
+     Update a running Adler-32 checksum with the bytes buf[0..len-1] and
+   return the updated checksum. If buf is NULL, this function returns
+   the required initial value for the checksum.
+   An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
+   much faster. Usage example:
+
+     unsigned long adler = adler32(0L, Z_NULL, 0);
+
+     while (read_buffer(buffer, length) != EOF) {
+       adler = adler32(adler, buffer, length);
+     }
+     if (adler != original_adler) error();
+
+   Implementation notes:
+
+     This function isn't actually much faster than crc32(), but it is smaller
+   and does not use any lookup tables.
+*/
+
+
+unsigned long __fastcall__ crc32 (unsigned long crc, const char* buf,
+                                  unsigned len);
+/*
+   Original zlib description:
+
+     Update a running crc with the bytes buf[0..len-1] and return the updated
+   crc. If buf is NULL, this function returns the required initial value
+   for the crc. Pre- and post-conditioning (one's complement) is performed
+   within this function so it shouldn't be done by the application.
+   Usage example:
+
+     unsigned long crc = crc32(0L, Z_NULL, 0);
+
+     while (read_buffer(buffer, length) != EOF) {
+       crc = crc32(crc, buffer, length);
+     }
+     if (crc != original_crc) error();
+
+   Implementation notes:
+
+     This function uses statically allocated 1 KB lookup table. The table is
+   initialised before it is used for the first time (that is, if buffer is
+   NULL or length is zero, then the lookup table isn't initialised).
+*/
+
+
+/* end of zlib.h */
+#endif
+
+
+
index 54b54860c3ab9987bf35f0942be15c4d0b14946d..0583b6761271df364b9d229210139d59e1077aa8 100644 (file)
@@ -1,4 +1,3 @@
-
 ifneq ($(shell echo),)
   CMD_EXE = 1
 endif
@@ -15,24 +14,24 @@ CBMS = c128   \
 GEOS = geos-apple \
        geos-cbm
 
-TARGETS = apple2    \
-          apple2enh \
-          atari     \
-          atarixl   \
-          atari2600 \
-          atari5200 \
-          atmos     \
+TARGETS = apple2       \
+          apple2enh    \
+          atari        \
+          atarixl      \
+          atari2600    \
+          atari5200    \
+          atmos        \
           creativision \
-          $(CBMS)   \
-          $(GEOS)   \
-          gamate    \
-          lynx      \
-          nes       \
-          osic1p    \
-          pce       \
-          sim6502   \
-          sim65c02  \
-          supervision\
+          $(CBMS)      \
+          $(GEOS)      \
+          gamate       \
+          lynx         \
+          nes          \
+          osic1p       \
+          pce          \
+          sim6502      \
+          sim65c02     \
+          supervision  \
           telestrat
 
 DRVTYPES = emd \
@@ -41,13 +40,13 @@ DRVTYPES = emd \
            ser \
            tgi
 
-OUTPUTDIRS := lib                 \
-              asminc              \
-              cfg                 \
-              include             \
-              $(subst ../,,$(filter-out $(wildcard ../include/*.*),$(wildcard ../include/*)))\
-              $(subst ../,,$(wildcard ../target/*/drv/*))\
-              $(subst ../,,$(wildcard ../target/*/util))\
+OUTPUTDIRS := lib                                                                             \
+              asminc                                                                          \
+              cfg                                                                             \
+              include                                                                         \
+              $(subst ../,,$(filter-out $(wildcard ../include/*.*),$(wildcard ../include/*))) \
+              $(subst ../,,$(wildcard ../target/*/drv/*))                                     \
+              $(subst ../,,$(wildcard ../target/*/util))
 
 .PHONY: all mostlyclean clean install zip lib $(TARGETS)
 
@@ -73,7 +72,7 @@ endif
 
 ifndef TARGET
 
-datadir = $(prefix)/share/cc65
+datadir = $(PREFIX)/share/cc65
 
 all lib: $(TARGETS)
 
@@ -93,7 +92,7 @@ INSTALL = install
 
 define INSTALL_recipe
 
-$(if $(prefix),,$(error variable `prefix' must be set))
+$(if $(PREFIX),,$(error variable `PREFIX' must be set))
 $(INSTALL) -d $(DESTDIR)$(datadir)/$(dir)
 $(INSTALL) -m0644 ../$(dir)/*.* $(DESTDIR)$(datadir)/$(dir)
 
@@ -197,6 +196,7 @@ DEPS = $(OBJS:.o=.d)
 EXTRA_SRCPAT = $(SRCDIR)/extra/%.s
 EXTRA_OBJPAT = ../lib/$(TARGET)-%.o
 EXTRA_OBJS := $(patsubst $(EXTRA_SRCPAT),$(EXTRA_OBJPAT),$(wildcard $(SRCDIR)/extra/*.s))
+DEPS += $(EXTRA_OBJS:../lib/%.o=../libwrk/$(TARGET)/%.d)
 
 ZPOBJ = ../libwrk/$(TARGET)/zeropage.o
 ifeq ($(TARGET),$(filter $(TARGET),$(EXTZP)))
@@ -280,9 +280,9 @@ endef # COMPILE_recipe
 ../libwrk/$(TARGET)/%.o: %.c | ../libwrk/$(TARGET)
        $(COMPILE_recipe)
 
-$(EXTRA_OBJPAT): $(EXTRA_SRCPAT) | ../lib
+$(EXTRA_OBJPAT): $(EXTRA_SRCPAT) | ../libwrk/$(TARGET) ../lib
        @echo $(TARGET) - $(<F)
-       @$(CA65) -t $(TARGET) $(CA65FLAGS) -o $@ $<
+       @$(CA65) -t $(TARGET) $(CA65FLAGS) --create-dep $(@:../lib/%.o=../libwrk/$(TARGET)/%.d) -o $@ $<
 
 ../lib/$(TARGET).lib: $(OBJS) | ../lib
        $(AR65) a $@ $?
index e4097e04319f2bc2651655b0483efe597af7a5f1..ed208325504c6f353209931ebff3f2db7db66d9f 100644 (file)
@@ -46,17 +46,6 @@ PREAD   :=      $FB1E   ; Read paddle in X, return AD conv. value in Y
 
         .addr   $0000
 
-; Button state masks (8 values)
-
-        .byte   $10
-        .byte   $20
-        .byte   $04
-        .byte   $08
-        .byte   $40
-        .byte   $80
-        .byte   $00             ; Future expansion
-        .byte   $00             ; Future expansion
-
 ; Jump table
 
         .addr   INSTALL
@@ -119,7 +108,7 @@ READJOY:
         lda     BUTN0-1,x       ; Check button (1, 3)
         asl
         tya
-        ror                     ; FIRE DOWN !UP RIGHT !LEFT 0 0 0
+        ror                     ; BTN DOWN !UP RIGHT !LEFT 0 0 0
 
         ; Read secondary button
         tay
@@ -130,10 +119,10 @@ READJOY:
         lda     BUTN0-1,x       ; Check button (2, 0)
         asl
         tya
-        ror                     ; FIRE2 FIRE DOWN !UP RIGHT !LEFT 0 0
+        ror                     ; BTN2 BTN DOWN !UP RIGHT !LEFT 0 0
 
         ; Finalize
-        eor     #%00010100      ; FIRE2 FIRE DOWN UP RIGHT LEFT 0 0
+        eor     #%00010100      ; BTN2 BTN DOWN UP RIGHT LEFT 0 0
         ldx     #$00
         bit     $C080           ; Switch in LC bank 2 for R/O
         rts
index 2e9ebcb313ea045c86a581fe7b3ef37360624d01..f8d938dfbdacbd6b27164978d0f1bd172bde8358 100644 (file)
@@ -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
index 46766070b4c9335c84a3112d2e2c3d1150a287cc..0e8cd2a0a020836c15b2381d3e31d29a2930948a 100644 (file)
 
         .addr   $0000
 
-; Button state masks (8 values)
-
-        .byte   $02                     ; JOY_UP
-        .byte   $04                     ; JOY_DOWN
-        .byte   $08                     ; JOY_LEFT
-        .byte   $10                     ; JOY_RIGHT
-        .byte   $01                     ; JOY_FIRE
-        .byte   $00                     ; JOY_FIRE2 not available
-        .byte   $00                     ; Future expansion
-        .byte   $00                     ; Future expansion
-
 ; Jump table.
 
         .addr   INSTALL
@@ -115,10 +104,12 @@ READJOY:
 
 ; Read joystick
 
-        lda     PORTA           ; get position
-        and     #%00001111
+        lda     STRIG0          ; get button
+        asl     a
+        asl     a
+        asl     a
         asl     a
-        ora     TRIG0           ; add button information
-        eor     #%00011111
+        ora     PORTA           ; add position information
+        eor     #$1F
         ldx     #0              ; fix X
         rts
index fc7aa55f4cf04c49d885cf0c550fd6e02f6b1947..0c8799e21bcf072140dd9fcc70a904c3c2aabb0d 100644 (file)
 
         .addr   $0000
 
-; Button state masks (8 values)
-
-        .byte   $01                     ; JOY_UP
-        .byte   $02                     ; JOY_DOWN
-        .byte   $04                     ; JOY_LEFT
-        .byte   $08                     ; JOY_RIGHT
-        .byte   $10                     ; JOY_FIRE
-        .byte   $00                     ; JOY_FIRE2 not available
-        .byte   $00                     ; Future expansion
-        .byte   $00                     ; Future expansion
-
 ; Jump table.
 
         .addr   INSTALL
diff --git a/libsrc/atari/setcursor.s b/libsrc/atari/setcursor.s
new file mode 100644 (file)
index 0000000..cf596d4
--- /dev/null
@@ -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
index 3483cc11aed1109414ed641550d7357fd9f77f8a..0b8b93b63d443a72c60ee85cf7f1ebfb0ab1d45f 100644 (file)
 
         .addr   $0000
 
-; Button state masks (8 values)
-
-        .byte   $01             ; JOY_UP
-        .byte   $02             ; JOY_DOWN
-        .byte   $04             ; JOY_LEFT
-        .byte   $08             ; JOY_RIGHT
-        .byte   $10             ; JOY_FIRE
-        .byte   $20             ; JOY_FIRE2
-        .byte   $00             ; Future expansion
-        .byte   $00             ; Future expansion
-
 ; Jump table.
 
         .addr   INSTALL
@@ -99,7 +88,7 @@ READJOY:
         lda     #0              ; Initialize return value
         cmp     TRIG0,y
         bne     @notrg
-        lda     #$10            ; JOY_FIRE
+        lda     #$10            ; JOY_BTN
 
 ; Read joystick
 
index 80d4d52510fc94c7b86912ab26cfbd8a627a4b8b..6652c94193ba40a9f28c58a72d86f91980f3bc28 100644 (file)
@@ -1,14 +1,18 @@
 ;
-; Ullrich von Bassewitz, 2003-04-13
+; 2003-04-13, Ullrich von Bassewitz
+; 2017-06-15, Greg King
 ;
 ; void gotoxy (unsigned char x, unsigned char y);
 ;
 
-        .export         _gotoxy
+        .export         gotoxy, _gotoxy
+
         .import         popa
 
         .include        "atmos.inc"
 
+gotoxy: jsr     popa            ; Get Y
+
 .proc   _gotoxy
 
         sta     CURS_Y          ; Set Y
@@ -17,5 +21,3 @@
         rts
 
 .endproc
-
-
index 26d7c74d8be4b545de2a921673629a0bcdc50e74..637571c0461d2eece93190faf66b0be61c761f61 100644 (file)
 
         .addr   $0000
 
-; Button state masks (8 values)
-
-        .byte   $10                     ; JOY_UP
-        .byte   $08                     ; JOY_DOWN
-        .byte   $01                     ; JOY_LEFT
-        .byte   $02                     ; JOY_RIGHT
-        .byte   $20                     ; JOY_FIRE
-        .byte   $00                     ; Future expansion
-        .byte   $00                     ; Future expansion
-        .byte   $00                     ; Future expansion
-
 ; Jump table.
 
         .addr   INSTALL
index 6f65ce5eb4fef09198e9ca15072ffc89621a81ed..c9ae39a47734a271cb026a5af4d1ee3418fe6a54 100644 (file)
 
         .addr   $0000
 
-; Button state masks (8 values)
-
-        .byte   $01                     ; JOY_UP
-        .byte   $02                     ; JOY_DOWN
-        .byte   $04                     ; JOY_LEFT
-        .byte   $08                     ; JOY_RIGHT
-        .byte   $10                     ; JOY_FIRE
-        .byte   $00                     ; JOY_FIRE2 unavailable
-        .byte   $00                     ; Future expansion
-        .byte   $00                     ; Future expansion
-
 ; Jump table.
 
         .addr   INSTALL
index 119d3784f5b25aef7778e67fb7e3c8fe4facc057..943361da5ee526d6333aab406f16248aa409099e 100644 (file)
 
         .addr   $0000
 
-; Button state masks (8 values)
-
-        .byte   $01                     ; JOY_UP
-        .byte   $02                     ; JOY_DOWN
-        .byte   $04                     ; JOY_LEFT
-        .byte   $08                     ; JOY_RIGHT
-        .byte   $10                     ; JOY_FIRE
-        .byte   $00                     ; JOY_FIRE2 unavailable
-        .byte   $00                     ; Future expansion
-        .byte   $00                     ; Future expansion
-
 ; Jump table.
 
         .addr   INSTALL
@@ -104,7 +93,7 @@ joy1:   lda     #$7F
         sei
         sta     CIA1_PRA
         lda     CIA1_PRB
-        cli
+back:   cli
         and     #$1F
         eor     #$1F
         rts
@@ -118,9 +107,4 @@ joy2:   ldx     #0
         sta     CIA1_DDRA
         lda     CIA1_PRA
         sty     CIA1_DDRA
-        cli
-        and     #$1F
-        eor     #$1F
-        rts
-
-
+        jmp     back
diff --git a/libsrc/c128/kbrepeat.s b/libsrc/c128/kbrepeat.s
new file mode 100644 (file)
index 0000000..4b9bc22
--- /dev/null
@@ -0,0 +1,14 @@
+;
+; unsigned char __fastcall__ kbrepeat (unsigned char mode);
+;
+
+        .export _kbrepeat
+
+        .include        "c128.inc"
+
+_kbrepeat:
+        ldx KBDREPEAT           ; get old value
+        sta KBDREPEAT           ; store new value
+        txa                     ; return old value
+        ldx #0
+        rts
diff --git a/libsrc/c128/waitvsync.s b/libsrc/c128/waitvsync.s
new file mode 100644 (file)
index 0000000..e4bbbf7
--- /dev/null
@@ -0,0 +1,30 @@
+;
+; Written by Groepaz <groepaz@gmx.net>
+;
+; void waitvsync (void);
+;
+
+        .export         _waitvsync
+
+        .include        "c128.inc"
+
+_waitvsync:
+
+        bit     MODE
+        bmi     @c80
+
+@l1:
+        bit     VIC_CTRL1
+        bpl     @l1
+@l2:
+        bit     VIC_CTRL1
+        bmi     @l2
+        rts
+
+@c80:
+        ;FIXME: do we have to switch banks?
+@l3:
+        lda     VDC_INDEX
+        and     #$20
+        beq     @l3
+        rts
index bf44a0ecc522c251e45cf5130cdd45792effed04..39f323d28f3c4ee9f69ab66e0a9545a8d6e6e9f6 100644 (file)
-;\r
-; Extended memory driver for 65816 based extra RAM. Driver works without\r
-; problems when statically linked.\r
-;\r
-; Marco van den Heuvel, 2015-12-01\r
-;\r
-\r
-        .include        "zeropage.inc"\r
-\r
-        .include        "em-kernel.inc"\r
-        .include        "em-error.inc"\r
-\r
-\r
-        .macpack        generic\r
-        .macpack        module\r
-\r
-\r
-; ------------------------------------------------------------------------\r
-; Header. Includes jump table\r
-\r
-        module_header   _c64_65816_emd\r
-\r
-; Driver signature\r
-\r
-        .byte   $65, $6d, $64           ; "emd"\r
-        .byte   EMD_API_VERSION         ; EM API version number\r
-\r
-; Library reference\r
-\r
-        .addr   $0000\r
-\r
-; Jump table\r
-\r
-        .addr   INSTALL\r
-        .addr   UNINSTALL\r
-        .addr   PAGECOUNT\r
-        .addr   MAP\r
-        .addr   USE\r
-        .addr   COMMIT\r
-        .addr   COPYFROM\r
-        .addr   COPYTO\r
-\r
-; ------------------------------------------------------------------------\r
-; Data.\r
-\r
-.bss\r
-isnotscpu:      .res    1               ; SuperCPU not present\r
-curpage:        .res    1               ; Current page number\r
-curbank:        .res    1               ; Current bank number (+1)\r
-bankcount:      .res    1               ; Number of available banks (pages = banks * 256)\r
-window:         .res    256             ; Memory "window"\r
-\r
-.code\r
-\r
-; ------------------------------------------------------------------------\r
-; INSTALL routine. Is called after the driver is loaded into memory. If\r
-; possible, check if the hardware is present and determine the amount of\r
-; memory available.\r
-; Must return an EM_ERR_xx code in a/x.\r
-;\r
-\r
-INSTALL:\r
-        sei\r
-        clc\r
-        sed\r
-        lda     #$99\r
-        adc     #$01                    ; on 65C02, 65SC02, 65CE02, 65802 and 65816 sets the zero flag correctly\r
-        cld\r
-        bne     @not_present\r
-        clc\r
-.P816\r
-        sep     #$01                    ; nop #$01 on 65C02/65SC02 and lda ($01,s),y on 65CE02\r
-.P02\r
-        bcc     @not_present\r
-        lda     $d0bc\r
-        and     #$80\r
-        sta     isnotscpu\r
-        lda     $07e8\r
-        pha                             ; save value incase it was used somewhere else\r
-        ldx     #$ff\r
-@fillloop:                              ; fill from top (bank 255) to bottom\r
-        txa\r
-        pha\r
-.P816\r
-        plb                             ; pull dbr\r
-.P02\r
-        stx     $07e8\r
-        dex\r
-        cpx     #$ff\r
-        bne     @fillloop\r
-        inx\r
-@compareloop:                           ; check from bottom to top\r
-        txa\r
-        pha\r
-.P816\r
-        plb\r
-.P02\r
-        cmp     $07e8\r
-        bne     @found_pages\r
-.P816\r
-        inc\r
-.P02\r
-        sta     $07e8\r
-        cmp     $07e8\r
-        bne     @found_pages\r
-        inx\r
-        bne     @compareloop\r
-@found_pages:\r
-        dex\r
-        lda     #$00\r
-        pha\r
-.P816\r
-        plb\r
-.P02\r
-        pla\r
-        sta     $07e8\r
-        cli\r
-        lda     isnotscpu\r
-        bne     @noextradex\r
-        dex\r
-@noextradex:\r
-        stx     bankcount\r
-        lda     #<EM_ERR_OK\r
-        ldx     #>EM_ERR_OK\r
-        rts\r
-@not_present:\r
-        cli\r
-        lda     #<EM_ERR_NO_DEVICE\r
-        ldx     #>EM_ERR_NO_DEVICE\r
-;       rts                             ; Run into UNINSTALL instead\r
-\r
-\r
-; ------------------------------------------------------------------------\r
-; UNINSTALL routine. Is called before the driver is removed from memory.\r
-; Can do cleanup or whatever. Must not return anything.\r
-;\r
-\r
-UNINSTALL:\r
-        rts\r
-\r
-\r
-; ------------------------------------------------------------------------\r
-; PAGECOUNT: Return the total number of available pages in a/x.\r
-;\r
-\r
-PAGECOUNT:\r
-        lda     #$00                   ; a whole bank is either usable or not\r
-        ldx     bankcount\r
-        rts\r
-\r
-; ------------------------------------------------------------------------\r
-; MAP: Map the page in a/x into memory and return a pointer to the page in\r
-; a/x. The contents of the currently mapped page (if any) may be discarded\r
-; by the driver.\r
-;\r
-\r
-MAP:    sta     curpage                 ; Remember the new page\r
-        stx     curbank                 ; Remember the new bank\r
-\r
-        sta     ptr2+1                  ; src address low\r
-        lda     #$00\r
-        sta     ptr2                    ; src address high\r
-        inx\r
-        ldy     isnotscpu               ; check if not scpu\r
-        bne     @notscpu\r
-        inx\r
-@notscpu:\r
-        stx     tmp2                    ; src bank\r
-\r
-        sta     tmp1                    ; dst bank\r
-\r
-        sta     ptr3+1                  ; length high\r
-        lda     #$ff\r
-        sta     ptr3                    ; length low\r
-\r
-        lda     #<window\r
-        sta     ptr1                    ; dst address low\r
-        ldx     #>window\r
-        stx     ptr1+1                  ; dst address high\r
-\r
-        jsr     transfer\r
-\r
-        rts\r
-\r
-; ------------------------------------------------------------------------\r
-; USE: Tell the driver that the window is now associated with a given page.\r
-\r
-USE:    sta     curpage                 ; Remember the page\r
-        stx     curbank                 ; Remember the bank\r
-        lda     #<window\r
-        ldx     #>window                ; Return the window\r
-        rts\r
-\r
-; ------------------------------------------------------------------------\r
-; COMMIT: Commit changes in the memory window to extended storage.\r
-\r
-COMMIT: lda     curpage                 ; Get the current page\r
-        sta     ptr1+1                  ; dst high\r
-        ldx     #$00\r
-        stx     ptr1                    ; dst low\r
-\r
-        lda     #<window\r
-        sta     ptr2                    ; src low\r
-        lda     #>window\r
-        sta     ptr2+1                  ; src high\r
-\r
-        stx     ptr3+1                  ; length high\r
-        lda     #$ff\r
-        sta     ptr3                    ; length low\r
-\r
-        stx     tmp2                    ; src bank\r
-        ldy     curbank                 ; Get the current bank\r
-        iny\r
-        ldx     isnotscpu\r
-        bne     @notascpu\r
-        iny\r
-@notascpu:\r
-        sty     tmp1                    ; dst bank\r
-\r
-        jsr     transfer\r
-\r
-        rts\r
-\r
-; ------------------------------------------------------------------------\r
-; COPYFROM: Copy from extended into linear memory. A pointer to a structure\r
-; describing the request is passed in a/x.\r
-; The function must not return anything.\r
-;\r
-\r
-COPYFROM:\r
-        sta     ptr4\r
-        stx     ptr4+1                  ; Save the passed em_copy pointer\r
-\r
-        ldy     #EM_COPY::COUNT+1       ; start at the end of the struct\r
-        lda     (ptr4),y                ; get high byte of count\r
-        tax\r
-        dey\r
-        lda     (ptr4),y                ; get low byte of count\r
-        bne     @nodex\r
-        dex\r
-@nodex:\r
-.P816\r
-        dec\r
-.P02\r
-        sta     ptr3                    ; length low\r
-        stx     ptr3+1                  ; length high\r
-        dey\r
-        lda     (ptr4),y                ; get bank\r
-.P816\r
-        inc\r
-.P02\r
-        ldx     isnotscpu\r
-        bne     @notscpu64\r
-.P816\r
-        inc\r
-.P02\r
-@notscpu64:\r
-        sta     tmp2                    ; src bank\r
-        dey\r
-        lda     (ptr4),y                ; get page\r
-        sta     ptr2+1                  ; src high\r
-        dey\r
-        lda     (ptr4),y                ; get offset in page\r
-        sta     ptr2                    ; src low\r
-        dey\r
-        lda     (ptr4),y                ; get memory buffer high\r
-        sta     ptr1+1                  ; dst high\r
-        dey\r
-        lda     (ptr4),y                ; get memory buffer low\r
-        sta     ptr1                    ; dst low\r
-        lda     #$00\r
-        sta     tmp1                    ; dst bank\r
-\r
-        jsr     transfer\r
-\r
-        rts\r
-\r
-; ------------------------------------------------------------------------\r
-; COPYTO: Copy from linear into extended memory. A pointer to a structure\r
-; describing the request is passed in a/x.\r
-; The function must not return anything.\r
-;\r
-\r
-COPYTO: sta     ptr4\r
-        stx     ptr4+1                  ; Save the passed em_copy pointer\r
-\r
-        ldy     #EM_COPY::COUNT+1       ; start at the end of the struct\r
-        lda     (ptr4),y                ; get high byte of count\r
-        tax\r
-        dey\r
-        lda     (ptr4),y                ; get low byte of count\r
-        bne     @nodex2\r
-        dex\r
-@nodex2:\r
-.P816\r
-        dec\r
-.P02\r
-        sta     ptr3                    ; length low\r
-        txa\r
-        sta     ptr3+1                  ; length high\r
-        dey\r
-        lda     (ptr4),y                ; get bank\r
-.P816\r
-        inc\r
-.P02\r
-        ldx     isnotscpu\r
-        bne     @notascpu64\r
-.P816\r
-        inc\r
-.P02\r
-@notascpu64:\r
-        sta     tmp1                    ; dst bank\r
-        dey\r
-        lda     (ptr4),y                ; get page\r
-        sta     ptr1+1                  ; dst high\r
-        dey\r
-        lda     (ptr4),y                ; get page offset\r
-        sta     ptr1                    ; dst low\r
-        dey\r
-        lda     (ptr4),y                ; get memory buffer high\r
-        sta     ptr2+1                  ; src low\r
-        dey\r
-        lda     (ptr4),y                ; get memory buffer low\r
-        sta     ptr2                    ; src high\r
-        lda     #$00\r
-        sta     tmp2                    ; src bank\r
-\r
-        jsr     transfer\r
-\r
-        rts\r
-\r
-; ------------------------------------------------------------------------\r
-; Helper function for moving a block, the following is used:\r
-; ptr1: dst\r
-; ptr2: src\r
-; ptr3: length\r
-; tmp1: dst bank\r
-; tmp2: src bank\r
-\r
-transfer:\r
-.P816\r
-.A8\r
-.I8\r
-        sei\r
-        pha\r
-        phx\r
-        phy\r
-        ldx     tmp1                    ; load srcbank\r
-        stx     @move+1                 ; store srcbank in move + 1\r
-        ldy     tmp2                    ; load dstbank\r
-        sty     @move+2                 ; store dstbank in move + 2\r
-        clc                             ; switch to native mode\r
-        xce\r
-        php                             ; save status bits\r
-        rep     #%00110000              ; set A and index to 16bit\r
-.A16\r
-.I16\r
-        ldy     ptr1\r
-        ldx     ptr2\r
-        lda     ptr3\r
-@move:\r
-        mvn 0,0\r
-        plp                             ; restore status bits\r
-.A8\r
-.I8\r
-        lda     #$00\r
-        pha\r
-        plb                             ; restore dbr\r
-        sec\r
-        xce                             ; switch to emul mode\r
-        ply\r
-        plx\r
-        pla\r
-        cli\r
-        rts\r
-.P02\r
+;
+; Extended memory driver for 65816 based extra RAM. Driver works without
+; problems when statically linked.
+;
+; Marco van den Heuvel, 2015-12-01
+;
+
+        .include        "zeropage.inc"
+
+        .include        "em-kernel.inc"
+        .include        "em-error.inc"
+
+
+        .macpack        generic
+        .macpack        module
+
+
+; ------------------------------------------------------------------------
+; Header. Includes jump table
+
+        module_header   _c64_65816_emd
+
+; Driver signature
+
+        .byte   $65, $6d, $64           ; "emd"
+        .byte   EMD_API_VERSION         ; EM API version number
+
+; Library reference
+
+        .addr   $0000
+
+; Jump table
+
+        .addr   INSTALL
+        .addr   UNINSTALL
+        .addr   PAGECOUNT
+        .addr   MAP
+        .addr   USE
+        .addr   COMMIT
+        .addr   COPYFROM
+        .addr   COPYTO
+
+; ------------------------------------------------------------------------
+; Data.
+
+.bss
+isnotscpu:      .res    1               ; SuperCPU not present
+curpage:        .res    1               ; Current page number
+curbank:        .res    1               ; Current bank number (+1)
+bankcount:      .res    1               ; Number of available banks (pages = banks * 256)
+window:         .res    256             ; Memory "window"
+
+.code
+
+; ------------------------------------------------------------------------
+; INSTALL routine. Is called after the driver is loaded into memory. If
+; possible, check if the hardware is present and determine the amount of
+; memory available.
+; Must return an EM_ERR_xx code in a/x.
+;
+
+INSTALL:
+        sei
+        clc
+        sed
+        lda     #$99
+        adc     #$01                    ; on 65C02, 65SC02, 65CE02, 65802 and 65816 sets the zero flag correctly
+        cld
+        bne     @not_present
+        clc
+.P816
+        sep     #$01                    ; nop #$01 on 65C02/65SC02 and lda ($01,s),y on 65CE02
+.P02
+        bcc     @not_present
+        lda     $d0bc
+        and     #$80
+        sta     isnotscpu
+        lda     $07e8
+        pha                             ; save value incase it was used somewhere else
+        ldx     #$ff
+@fillloop:                              ; fill from top (bank 255) to bottom
+        txa
+        pha
+.P816
+        plb                             ; pull dbr
+.P02
+        stx     $07e8
+        dex
+        cpx     #$ff
+        bne     @fillloop
+        inx
+@compareloop:                           ; check from bottom to top
+        txa
+        pha
+.P816
+        plb
+.P02
+        cmp     $07e8
+        bne     @found_pages
+.P816
+        inc
+.P02
+        sta     $07e8
+        cmp     $07e8
+        bne     @found_pages
+        inx
+        bne     @compareloop
+@found_pages:
+        dex
+        lda     #$00
+        pha
+.P816
+        plb
+.P02
+        pla
+        sta     $07e8
+        cli
+        lda     isnotscpu
+        bne     @noextradex
+        dex
+@noextradex:
+        stx     bankcount
+        lda     #<EM_ERR_OK
+        ldx     #>EM_ERR_OK
+        rts
+@not_present:
+        cli
+        lda     #<EM_ERR_NO_DEVICE
+        ldx     #>EM_ERR_NO_DEVICE
+;       rts                             ; Run into UNINSTALL instead
+
+
+; ------------------------------------------------------------------------
+; UNINSTALL routine. Is called before the driver is removed from memory.
+; Can do cleanup or whatever. Must not return anything.
+;
+
+UNINSTALL:
+        rts
+
+
+; ------------------------------------------------------------------------
+; PAGECOUNT: Return the total number of available pages in a/x.
+;
+
+PAGECOUNT:
+        lda     #$00                   ; a whole bank is either usable or not
+        ldx     bankcount
+        rts
+
+; ------------------------------------------------------------------------
+; MAP: Map the page in a/x into memory and return a pointer to the page in
+; a/x. The contents of the currently mapped page (if any) may be discarded
+; by the driver.
+;
+
+MAP:    sta     curpage                 ; Remember the new page
+        stx     curbank                 ; Remember the new bank
+
+        sta     ptr2+1                  ; src address low
+        lda     #$00
+        sta     ptr2                    ; src address high
+        inx
+        ldy     isnotscpu               ; check if not scpu
+        bne     @notscpu
+        inx
+@notscpu:
+        stx     tmp2                    ; src bank
+
+        sta     tmp1                    ; dst bank
+
+        sta     ptr3+1                  ; length high
+        lda     #$ff
+        sta     ptr3                    ; length low
+
+        lda     #<window
+        sta     ptr1                    ; dst address low
+        ldx     #>window
+        stx     ptr1+1                  ; dst address high
+
+        jsr     transfer
+
+        rts
+
+; ------------------------------------------------------------------------
+; USE: Tell the driver that the window is now associated with a given page.
+
+USE:    sta     curpage                 ; Remember the page
+        stx     curbank                 ; Remember the bank
+        lda     #<window
+        ldx     #>window                ; Return the window
+        rts
+
+; ------------------------------------------------------------------------
+; COMMIT: Commit changes in the memory window to extended storage.
+
+COMMIT: lda     curpage                 ; Get the current page
+        sta     ptr1+1                  ; dst high
+        ldx     #$00
+        stx     ptr1                    ; dst low
+
+        lda     #<window
+        sta     ptr2                    ; src low
+        lda     #>window
+        sta     ptr2+1                  ; src high
+
+        stx     ptr3+1                  ; length high
+        lda     #$ff
+        sta     ptr3                    ; length low
+
+        stx     tmp2                    ; src bank
+        ldy     curbank                 ; Get the current bank
+        iny
+        ldx     isnotscpu
+        bne     @notascpu
+        iny
+@notascpu:
+        sty     tmp1                    ; dst bank
+
+        jsr     transfer
+
+        rts
+
+; ------------------------------------------------------------------------
+; COPYFROM: Copy from extended into linear memory. A pointer to a structure
+; describing the request is passed in a/x.
+; The function must not return anything.
+;
+
+COPYFROM:
+        sta     ptr4
+        stx     ptr4+1                  ; Save the passed em_copy pointer
+
+        ldy     #EM_COPY::COUNT+1       ; start at the end of the struct
+        lda     (ptr4),y                ; get high byte of count
+        tax
+        dey
+        lda     (ptr4),y                ; get low byte of count
+        bne     @nodex
+        dex
+@nodex:
+.P816
+        dec
+.P02
+        sta     ptr3                    ; length low
+        stx     ptr3+1                  ; length high
+        dey
+        lda     (ptr4),y                ; get bank
+.P816
+        inc
+.P02
+        ldx     isnotscpu
+        bne     @notscpu64
+.P816
+        inc
+.P02
+@notscpu64:
+        sta     tmp2                    ; src bank
+        dey
+        lda     (ptr4),y                ; get page
+        sta     ptr2+1                  ; src high
+        dey
+        lda     (ptr4),y                ; get offset in page
+        sta     ptr2                    ; src low
+        dey
+        lda     (ptr4),y                ; get memory buffer high
+        sta     ptr1+1                  ; dst high
+        dey
+        lda     (ptr4),y                ; get memory buffer low
+        sta     ptr1                    ; dst low
+        lda     #$00
+        sta     tmp1                    ; dst bank
+
+        jsr     transfer
+
+        rts
+
+; ------------------------------------------------------------------------
+; COPYTO: Copy from linear into extended memory. A pointer to a structure
+; describing the request is passed in a/x.
+; The function must not return anything.
+;
+
+COPYTO: sta     ptr4
+        stx     ptr4+1                  ; Save the passed em_copy pointer
+
+        ldy     #EM_COPY::COUNT+1       ; start at the end of the struct
+        lda     (ptr4),y                ; get high byte of count
+        tax
+        dey
+        lda     (ptr4),y                ; get low byte of count
+        bne     @nodex2
+        dex
+@nodex2:
+.P816
+        dec
+.P02
+        sta     ptr3                    ; length low
+        txa
+        sta     ptr3+1                  ; length high
+        dey
+        lda     (ptr4),y                ; get bank
+.P816
+        inc
+.P02
+        ldx     isnotscpu
+        bne     @notascpu64
+.P816
+        inc
+.P02
+@notascpu64:
+        sta     tmp1                    ; dst bank
+        dey
+        lda     (ptr4),y                ; get page
+        sta     ptr1+1                  ; dst high
+        dey
+        lda     (ptr4),y                ; get page offset
+        sta     ptr1                    ; dst low
+        dey
+        lda     (ptr4),y                ; get memory buffer high
+        sta     ptr2+1                  ; src low
+        dey
+        lda     (ptr4),y                ; get memory buffer low
+        sta     ptr2                    ; src high
+        lda     #$00
+        sta     tmp2                    ; src bank
+
+        jsr     transfer
+
+        rts
+
+; ------------------------------------------------------------------------
+; Helper function for moving a block, the following is used:
+; ptr1: dst
+; ptr2: src
+; ptr3: length
+; tmp1: dst bank
+; tmp2: src bank
+
+transfer:
+.P816
+.A8
+.I8
+        sei
+        pha
+        phx
+        phy
+        ldx     tmp1                    ; load srcbank
+        stx     @move+1                 ; store srcbank in move + 1
+        ldy     tmp2                    ; load dstbank
+        sty     @move+2                 ; store dstbank in move + 2
+        clc                             ; switch to native mode
+        xce
+        php                             ; save status bits
+        rep     #%00110000              ; set A and index to 16bit
+.A16
+.I16
+        ldy     ptr1
+        ldx     ptr2
+        lda     ptr3
+@move:
+        mvn 0,0
+        plp                             ; restore status bits
+.A8
+.I8
+        lda     #$00
+        pha
+        plb                             ; restore dbr
+        sec
+        xce                             ; switch to emul mode
+        ply
+        plx
+        pla
+        cli
+        rts
+.P02
index a798100a79283fbcd83efaa5ea0acb4f7145d858..10c936399563265f83d7268af333d14706e8171e 100644 (file)
 
         .addr   $0000
 
-; Button state masks (8 values)
-
-        .byte   $01                     ; JOY_UP
-        .byte   $02                     ; JOY_DOWN
-        .byte   $04                     ; JOY_LEFT
-        .byte   $08                     ; JOY_RIGHT
-        .byte   $10                     ; JOY_FIRE
-        .byte   $00                     ; JOY_FIRE2 unavailable
-        .byte   $00                     ; Future expansion
-        .byte   $00                     ; Future expansion
-
 ; Jump table.
 
         .addr   INSTALL
index 5f6464215648cf8fe7075293ddf42d74204459d5..5ed7af18771100e1d6750d08d8f60e0edc4a046e 100644 (file)
 
         .addr   $0000
 
-; Button state masks (8 values)
-
-        .byte   $02                     ; JOY_UP        "8"
-        .byte   $10                     ; JOY_DOWN      "2"
-        .byte   $20                     ; JOY_LEFT      "4"
-        .byte   $08                     ; JOY_RIGHT     "6"
-        .byte   $04                     ; JOY_FIRE      "5" ENTER
-        .byte   $00                     ; JOY_FIRE2 unavailable
-        .byte   $00                     ; Future expansion
-        .byte   $00                     ; Future expansion
-
 ; Jump table.
 
         .addr   INSTALL
@@ -58,6 +47,49 @@ JOY_COUNT       = 1             ; Number of joysticks we support
 ; ------------------------------------------------------------------------
 ; Data.
 
+.rodata
+
+; <U>p      '8' key
+; <D>own    '2' key
+; <L>eft    '4' key
+; <R>ight   '6' key
+; <B>utton  '5' or ENTER key
+
+masktable:
+        ; Input:  LDRBU
+        ; Output: BRLDU
+        .byte %00000000         ; $00
+        .byte %00000001         ; $01
+        .byte %00010000         ; $02
+        .byte %00010001         ; $03
+        .byte %00001000         ; $04
+        .byte %00001001         ; $05
+        .byte %00011000         ; $06
+        .byte %00011001         ; $07
+        .byte %00000010         ; $08
+        .byte %00000011         ; $09
+        .byte %00010010         ; $0A
+        .byte %00010011         ; $0B
+        .byte %00001010         ; $0C
+        .byte %00001011         ; $0D
+        .byte %00011010         ; $0E
+        .byte %00011011         ; $0F
+        .byte %00000100         ; $10
+        .byte %00000101         ; $11
+        .byte %00010100         ; $12
+        .byte %00010101         ; $13
+        .byte %00001100         ; $14
+        .byte %00001101         ; $15
+        .byte %00011100         ; $16
+        .byte %00011101         ; $17
+        .byte %00000110         ; $18
+        .byte %00000111         ; $19
+        .byte %00010110         ; $1A
+        .byte %00010111         ; $1B
+        .byte %00001110         ; $1C
+        .byte %00001111         ; $1D
+        .byte %00011110         ; $1E
+        .byte %00011111         ; $1F
 
 .code
 
@@ -100,21 +132,23 @@ COUNT:  lda     #JOY_COUNT
 ;
 
 READ:   tax                     ; Clear high byte
-        lda     #$FD
-        ldy     #$FE
+        lda     #$FD            ; For ENTER and '6'
+        ldy     #$FE            ; For '8', '5', '2', '4'
         sei
         sta     VIC_KBD_128
         lda     CIA1_PRB
         and     #%00110000
         eor     #%00110000
-        lsr
-        lsr
+        lsr                     ; Map ENTER ...
+        lsr                     ; ... onto '5'
         sty     VIC_KBD_128
         eor     CIA1_PRB
         iny
         sty     VIC_KBD_128     ; Reset to $FF
         cli
-        and     #%11111110
-        eor     #%11111110
+        and     #%00111110
+        eor     #%00111110
+        lsr
+        tay
+        lda     masktable,y     ; Convert LDRBU to BRLDU
         rts
-
index 31850488c44dbb98ed7effbc905155ae5abd3d36..af5c27e134060dc8dd78532bede298b8afaadaf1 100644 (file)
 
         .addr   $0000
 
-; Button state masks (8 values)
-
-        .byte   $01                     ; JOY_UP
-        .byte   $02                     ; JOY_DOWN
-        .byte   $04                     ; JOY_LEFT
-        .byte   $08                     ; JOY_RIGHT
-        .byte   $10                     ; JOY_FIRE
-        .byte   $00                     ; JOY_FIRE2 unavailable
-        .byte   $00                     ; Future expansion
-        .byte   $00                     ; Future expansion
-
 ; Jump table.
 
         .addr   INSTALL
@@ -133,8 +122,8 @@ joy3:
         sta     CIA2_PRB        ; (output one at PB7)
 
         lda     CIA2_PRB        ; cia 2 port B read/write
-        and     #$1f            ; get bit 4-0 (PB4-PB0)
-        eor     #$1f
+        and     #$1F            ; get bit 4-0 (PB4-PB0)
+        eor     #$1F
         rts
 
 ; Read joystick 4
@@ -143,14 +132,14 @@ joy4:   lda     #$00            ; cia 2 port B read/write
         sta     CIA2_PRB        ; (output zero at PB7)
 
         lda     CIA2_PRB        ; cia 2 port B read/write
-        and     #$0f            ; get bit 3-0 (PB3-PB0)
+        and     #$0F            ; get bit 3-0 (PB3-PB0)
         sta     tmp1            ; joy 4 directions
 
         lda     CIA2_PRB        ; cia 2 port B read/write
         and     #%00100000      ; get bit 5 (PB5)
         lsr
         ora     tmp1
-        eor     #$1f
+        eor     #$1F
 
         ldx #0
         rts
index 2932c77fdd34d06c3b174c941547e79c1eea0036..930ad6227138d2afab6151e30d7df33d6441ee7c 100644 (file)
 
         .addr   $0000
 
-; Button state masks (8 values)
-
-        .byte   $01                     ; JOY_UP
-        .byte   $02                     ; JOY_DOWN
-        .byte   $04                     ; JOY_LEFT
-        .byte   $08                     ; JOY_RIGHT
-        .byte   $10                     ; JOY_FIRE
-        .byte   $00                     ; JOY_FIRE2 unavailable
-        .byte   $00                     ; Future expansion
-        .byte   $00                     ; Future expansion
-
 ; Jump table.
 
         .addr   INSTALL
diff --git a/libsrc/c64/kbrepeat.s b/libsrc/c64/kbrepeat.s
new file mode 100644 (file)
index 0000000..0df13e5
--- /dev/null
@@ -0,0 +1,14 @@
+;
+; unsigned char __fastcall__ kbrepeat (unsigned char mode);
+;
+
+        .export _kbrepeat
+
+        .include        "c64.inc"
+
+_kbrepeat:
+        ldx KBDREPEAT           ; get old value
+        sta KBDREPEAT           ; store new value
+        txa                     ; return old value
+        ldx #0
+        rts
diff --git a/libsrc/c64/waitvsync.s b/libsrc/c64/waitvsync.s
new file mode 100644 (file)
index 0000000..a4bf130
--- /dev/null
@@ -0,0 +1,18 @@
+;
+; Written by Groepaz <groepaz@gmx.net>
+;
+; void waitvsync (void);
+;
+
+        .export         _waitvsync
+
+        .include        "c64.inc"
+
+_waitvsync:
+@l1:
+        bit     VIC_CTRL1
+        bpl     @l1
+@l2:
+        bit     VIC_CTRL1
+        bmi     @l2
+        rts
index 7133f9379a83203361dbe01048201e3b5503b681..0c2efc12d3b2999395da8a813b8374e3daea11f6 100644 (file)
 
         .addr   $0000
 
-; Button state masks (8 values)
-
-        .byte   $01                     ; JOY_UP
-        .byte   $02                     ; JOY_DOWN
-        .byte   $04                     ; JOY_LEFT
-        .byte   $08                     ; JOY_RIGHT
-        .byte   $10                     ; JOY_FIRE
-        .byte   $00                     ; JOY_FIRE2 unavailable
-        .byte   $00                     ; Future expansion
-        .byte   $00                     ; Future expansion
-
 ; Jump table.
 
         .addr   INSTALL
@@ -105,7 +94,7 @@ READ:   ldx     #$0F            ; Switch to the system bank
         lda     (cia2),y        ; Read joystick inputs
         sta     tmp1
 
-; Get the fire bits
+; Get the push button bits
 
         ldy     #CIA::PRA
         lda     (cia2),y
@@ -115,12 +104,12 @@ READ:   ldx     #$0F            ; Switch to the system bank
         cpx     #$00            ; Joystick 0?
         bne     @L1             ; Jump if no
 
-; Joystick 1, fire is in bit 6, direction in bit 0-3
+; Joystick 1, push button is in bit 6, direction in bit 0-3
 
         asl     a
         jmp     @L2
 
-; Joystick 2, fire is in bit 7, direction in bit 5-7
+; Joystick 2, push button is in bit 7, direction in bit 5-7
 
 @L1:    ldx     #$00            ; High byte of return value
         lsr     tmp1
@@ -128,9 +117,9 @@ READ:   ldx     #$0F            ; Switch to the system bank
         lsr     tmp1
         lsr     tmp1
 
-; Mask the relavant bits, get the fire bit
+; Mask the relavant bits, get the push button bit
 
-@L2:    asl     a               ; Fire bit into carry
+@L2:    asl     a               ; push button bit into carry
         lda     tmp1
         and     #$0F
         bcc     @L3
diff --git a/libsrc/cbm510/waitvsync.s b/libsrc/cbm510/waitvsync.s
new file mode 100644 (file)
index 0000000..ed7300f
--- /dev/null
@@ -0,0 +1,28 @@
+;
+; Written by Groepaz <groepaz@gmx.net>
+;
+; void waitvsync (void);
+;
+
+        .export         _waitvsync
+        .import         PALFLAG
+        .import         sys_bank, restore_bank
+
+        .importzp       vic
+
+        .include        "cbm510.inc"
+
+_waitvsync:
+        jsr     sys_bank        ; Switch to the system bank
+        sei
+
+        ldy     #VIC_CTRL1
+@l1:
+        lda     (vic),y
+        bpl     @l1
+@l2:
+        lda     (vic),y
+        bmi     @l2
+
+        cli
+        jmp        restore_bank
diff --git a/libsrc/common/lz4.s b/libsrc/common/lz4.s
new file mode 100644 (file)
index 0000000..4702137
--- /dev/null
@@ -0,0 +1,286 @@
+;
+; Lauri Kasanen, 6 Jun 2017
+; (C) Mega Cat Studios
+; An optimized LZ4 decompressor
+;
+; Almost 7 times faster, uses no RAM (vs 14 bytes BSS), and takes 1/4 the space
+; vs the official C source.
+;
+
+        .importzp       sp, sreg, regsave, regbank
+        .importzp       tmp1, tmp2, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4
+        .macpack        longbranch
+        .import         memcpy_upwards,pushax,popax
+        .export         _decompress_lz4
+
+out = regsave
+written = regsave + 2
+tmp = tmp1
+token = tmp2
+offset = ptr3
+in = sreg
+outlen = ptr4
+
+; ---------------------------------------------------------------
+; void decompress_lz4 (const u8 *in, u8 * const out, const u16 outlen)
+; ---------------------------------------------------------------
+
+.segment        "CODE"
+
+.proc   _decompress_lz4: near
+
+        sta     outlen
+        stx     outlen+1
+
+        jsr     popax
+        sta     out
+        stx     out+1
+
+        jsr     popax
+        sta     in
+        stx     in+1
+
+;
+; written = 0;
+;
+        lda     #$00
+        sta     written
+;
+; while (written < outlen) {
+;
+        jmp     L0046
+;
+; token = *in++;
+;
+L0004:  ldy     #$00
+        lda     (in),y
+        sta     token
+
+        inc     in
+        bne     L000A
+        inc     in+1
+L000A:
+;
+; offset = token >> 4;
+;
+        ldx     #$00
+        lsr     a
+        lsr     a
+        lsr     a
+        lsr     a
+        sta     offset
+        stx     offset+1
+;
+; token &= 0xf;
+; token += 4; // Minmatch
+;
+        lda     token
+        and     #$0F
+        clc
+        adc     #$04
+        sta     token
+;
+; if (offset == 15) {
+;
+        lda     offset
+        cmp     #$0F
+L0013:  bne     L001A
+;
+; tmp = *in++;
+;
+        ldy     #$00
+        lda     (in),y
+        sta     tmp
+
+        inc     in
+        bne     L0017
+        inc     in+1
+L0017:
+;
+; offset += tmp;
+;
+        clc
+        adc     offset
+        sta     offset
+        lda     #$00
+        adc     offset+1
+        sta     offset+1
+;
+; if (tmp == 255)
+;
+        lda     tmp
+        cmp     #$FF
+;
+; goto moreliterals;
+;
+        jmp     L0013
+;
+; if (offset) {
+;
+L001A:  lda     offset
+        ora     offset+1
+        beq     L001C
+;
+; memcpy(&out[written], in, offset);
+;
+        lda     out
+        clc
+        adc     written
+        sta     ptr2
+        lda     out+1
+        adc     written+1
+        tax
+        lda     ptr2
+        stx     ptr2+1
+        jsr     pushax
+        lda     in
+        ldx     in+1
+        sta     ptr1
+        stx     ptr1+1
+;        ldy     #$00 - not needed as pushax zeroes Y
+        jsr     memcpy_upwards
+;
+; written += offset;
+;
+        lda     offset
+        clc
+        adc     written
+        sta     written
+        lda     offset+1
+        adc     written+1
+        sta     written+1
+;
+; in += offset;
+;
+        lda     offset
+        clc
+        adc     in
+        sta     in
+        lda     offset+1
+        adc     in+1
+        sta     in+1
+;
+; if (written >= outlen)
+;
+L001C:  lda     written
+        cmp     outlen
+        lda     written+1
+        sbc     outlen+1
+;
+; return;
+;
+        bcc     L0047
+        rts
+;
+; memcpy(&offset, in, 2);
+;
+L0047:  ldy     #$00
+        lda     (in),y
+        sta     offset
+        iny
+        lda     (in),y
+        sta     offset+1
+;
+; in += 2;
+;
+        lda     #$02
+        clc
+        adc     in
+        sta     in
+        bcc     L002F
+        inc     in+1
+;
+; copysrc = out + written - offset;
+;
+L002F:  lda     out
+        clc
+        adc     written
+        tay
+        lda     out+1
+        adc     written+1
+        tax
+        tya
+        sec
+        sbc     offset
+        sta     ptr1
+        txa
+        sbc     offset+1
+        sta     ptr1+1
+;
+; offset = token;
+;
+        lda     #$00
+        sta     offset+1
+        lda     token
+        sta     offset
+;
+; if (token == 19) {
+;
+        cmp     #$13
+L0045:  bne     L003C
+;
+; tmp = *in++;
+;
+        ldy     #$00
+        lda     (in),y
+        sta     tmp
+
+        inc     in
+        bne     L0039
+        inc     in+1
+L0039:
+;
+; offset += tmp;
+;
+        clc
+        adc     offset
+        sta     offset
+        tya
+        adc     offset+1
+        sta     offset+1
+;
+; if (tmp == 255)
+;
+        lda     tmp
+        cmp     #$FF
+;
+; goto morematches;
+;
+        jmp     L0045
+;
+; memcpy(&out[written], copysrc, offset);
+;
+L003C:  lda     out
+        clc
+        adc     written
+        sta     ptr2
+        lda     out+1
+        adc     written+1
+        tax
+        lda     ptr2
+        stx     ptr2+1
+        jsr     pushax
+        jsr     memcpy_upwards
+;
+; written += offset;
+;
+        lda     offset
+        clc
+        adc     written
+        sta     written
+        lda     offset+1
+        adc     written+1
+L0046:  sta     written+1
+;
+; while (written < outlen) {
+;
+        lda     written
+        cmp     outlen
+        lda     written+1
+        sbc     outlen+1
+        jcc     L0004
+
+        rts
+
+.endproc
+
index 9c33124f19e2b1d1d3b33fe13f94d4fc2faff2fa..666447cd8cbea36992847ba02a93dbea615c2b67 100644 (file)
@@ -1,6 +1,6 @@
 ;
 ; 2003-08-20, Ullrich von Bassewitz
-; 2009-09-13, Christian Krueger -- performance increase (about 20%)
+; 2009-09-13, Christian Krueger -- performance increase (about 20%), 2013-07-25 improved unrolling
 ; 2015-10-23, Greg King
 ;
 ; void* __fastcall__ memmove (void* dest, const void* src, size_t size);
@@ -61,13 +61,10 @@ PageSizeCopy:                   ; assert Y = 0
         dec     ptr1+1          ; adjust base...
         dec     ptr2+1
         dey                     ; in entry case: 0 -> FF
-        lda     (ptr1),y        ; need to copy this 'intro byte'
-        sta     (ptr2),y        ; to 'land' later on Y=0! (as a result of the '.repeat'-block!)
-        dey                     ; FF ->FE
 @copyBytes:
-        .repeat 2               ; Unroll this a bit to make it faster...
-        lda     (ptr1),y
-        sta     (ptr2),y
+        .repeat 3               ; unroll this a bit to make it faster...
+        lda     (ptr1),y        ; important: unrolling three times gives a nice
+        sta     (ptr2),y        ; 255/3 = 85 loop which ends at 0
         dey
         .endrepeat
 @copyEntry:                     ; in entry case: 0 -> FF
index 8ad7bcdb48bd575539948fdc6852b3dfdd992f46..102dd5be2fa9c5a34123b91b4d2cef8583ddcc95 100644 (file)
@@ -2,6 +2,7 @@
 ; Randum number generator
 ;
 ; Written and donated by Sidney Cadot - sidney@ch.twi.tudelft.nl
+; 2016-11-07, modified by Brad Smith
 ;
 ; May be distributed with the cc65 runtime using the same license.
 ;
 ;  Multiplier must be 1 (mod 4)
 ;  Added value must be 1 (mod 2)
 ;  This guarantees max. period (2**32)
-;  Bits 8-22 are returned (positive 2-byte int)
-;  where 0 is LSB, 31 is MSB.
-;  This is better as lower bits exhibit easily
-;  detectable patterns.
+;  The lowest bits have poor entropy and
+;  exhibit easily detectable patterns, so
+;  only the upper bits 16-22 and 24-31 of the
+;  4-byte state are returned.
+;
+;  The best 8 bits, 24-31 are returned in the
+;  low byte A to provide the best entropy in the
+;  most commonly used part of the return value.
 ;
 
         .export         _rand, _srand
index 7784d89f762bc42be2577a4393976bad49c4c7d4..f9cd94633a36f2f4ac4d0464c1267c656cd0286e 100644 (file)
@@ -1,5 +1,6 @@
 ;
 ; Ullrich von Bassewitz, 31.05.1998
+; Christian Krueger: 2013-Jul-24, minor optimizations
 ;
 ; char* strcat (char* dest, const char* src);
 ;
@@ -7,49 +8,44 @@
         .export         _strcat
         .import         popax
         .importzp       ptr1, ptr2, tmp3
+        .macpack        cpu
 
 _strcat:
-        sta     ptr1            ; Save src
-        stx     ptr1+1
-        jsr     popax           ; Get dest
-        sta     ptr2
-        stx     ptr2+1
-        sta     tmp3            ; Remember for function return
-        ldy     #0
-
-; find end of dest
-
-sc1:    lda     (ptr2),y
-        beq     sc2
+        sta ptr1        ; Save src
+        stx ptr1+1
+        jsr popax       ; Get dest
+        sta tmp3        ; Remember for function return
+        tay
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+        stz ptr2
+.else
+        lda #0
+        sta ptr2        ; access from page start, y contains low byte
+.endif
+        stx ptr2+1
+
+findEndOfDest:
+        lda (ptr2),y
+        beq endOfDestFound
         iny
-        bne     sc1
-        inc     ptr2+1
-        bne     sc1
-
-; end found, get offset in y into pointer
-
-sc2:    tya
-        clc
-        adc     ptr2
-        sta     ptr2
-        bcc     sc3
-        inc     ptr2+1
-
-; copy src
-
-sc3:    ldy     #0
-sc4:    lda     (ptr1),y
-        sta     (ptr2),y
-        beq     sc5
+        bne findEndOfDest
+        inc ptr2+1
+        bne findEndOfDest
+
+endOfDestFound:
+        sty ptr2        ; advance pointer to last y position
+        ldy #0          ; reset new y-offset
+
+copyByte:
+        lda (ptr1),y
+        sta (ptr2),y
+        beq done
         iny
-        bne     sc4
-        inc     ptr1+1
-        inc     ptr2+1
-        bne     sc4
-
-; done, return pointer to dest
+        bne copyByte
+        inc ptr1+1
+        inc ptr2+1
+        bne copyByte    ; like bra here
 
-sc5:    lda     tmp3            ; X does still contain high byte
+; return pointer to dest
+done:   lda tmp3        ; X does still contain high byte
         rts
-
-
index 308381b06e1954fa6612076dd4a144ecea811df0..206b5160e560391ecbc57d4322778c88a9847a14 100644 (file)
@@ -1,5 +1,6 @@
 ;
 ; Ullrich von Bassewitz, 31.05.1998
+; Christian Krueger, 2013-Aug-04, minor optimization
 ;
 ; const char* strchr (const char* s, int c);
 ;
@@ -7,42 +8,45 @@
         .export         _strchr
         .import         popax
         .importzp       ptr1, tmp1
+        .macpack        cpu
 
 _strchr:
-        sta     tmp1            ; Save c
-        jsr     popax           ; get s
-        sta     ptr1
-        stx     ptr1+1
-        ldy     #0
-
-Loop:   lda     (ptr1),y        ; Get next char
-        beq     EOS             ; Jump on end of string
-        cmp     tmp1            ; Found?
-        beq     Found           ; Jump if yes
+        sta tmp1        ; Save c
+        jsr popax       ; get s
+        tay             ; low byte of pointer to y
+        stx ptr1+1
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+        stz ptr1
+.else
+        lda #0
+        sta ptr1        ; access from page start, y contains low byte
+.endif
+
+Loop:   lda (ptr1),y    ; Get next char
+        beq EOS         ; Jump on end of string
+        cmp tmp1        ; Found?
+        beq Found       ; Jump if yes
         iny
-        bne     Loop
-        inc     ptr1+1
-        bne     Loop            ; Branch always
+        bne Loop
+        inc ptr1+1
+        bne Loop        ; Branch always
 
 ; End of string. Check if we're searching for the terminating zero
 
-EOS:    lda     tmp1            ; Get the char we're searching for
-        bne     NotFound        ; Jump if not searching for terminator
+EOS:
+        lda tmp1        ; Get the char we're searching for
+        bne NotFound    ; Jump if not searching for terminator
 
-; Found. Calculate pointer to c.
+; Found. Set pointer to c.
 
-Found:  ldx     ptr1+1          ; Load high byte of pointer
-        tya                     ; Low byte offset          
-        clc
-        adc     ptr1
-        bcc     Found1
-        inx
-Found1: rts
+Found:
+        ldx ptr1+1      ; Load high byte of pointer
+        tya             ; low byte is in y
+        rts
 
 ; Not found, return NULL
 
 NotFound:
-        lda     #0
+        lda #0
         tax
         rts
-
index 8fd567ae4417ce8f3b4dd887662e6036bf001dc2..c9122dc9049363cba8305797da4d6102cb4874c6 100644 (file)
@@ -1,54 +1,53 @@
 ;
 ; Ullrich von Bassewitz, 11.06.1998
+; Christian Krueger: 05-Aug-2013, optimization
 ;
 ; size_t strcspn (const char* s1, const char* s2);
 ;
 
         .export         _strcspn
-        .import         popax
-        .importzp       ptr1, ptr2, tmp1, tmp2, tmp3
+        .import         popax, _strlen
+        .importzp       ptr1, ptr2, tmp1, tmp2
 
 _strcspn:
-        sta     ptr2            ; Save s2
-        stx     ptr2+1
-        jsr     popax           ; Get s1
-        sta     ptr1
-        stx     ptr1+1
-        ldx     #0              ; low counter byte
-        stx     tmp1            ; high counter byte
-        ldy     #$00
-
-L1:     lda     (ptr1),y        ; get next char from s1
-        beq     L6              ; jump if done
-        sta     tmp2            ; save char
-        iny
-        bne     L2
-        inc     ptr1+1
-L2:     sty     tmp3            ; save index into s1
-
-        ldy     #0              ; get index into s2
-L3:     lda     (ptr2),y        ;
-        beq     L4              ; jump if done
-        cmp     tmp2
-        beq     L6
+        jsr _strlen         ; get length in a/x and transfer s2 to ptr1
+                            ; Note: It does not make sense to
+                            ; have more than 255 test chars, so
+                            ; we don't support a high byte here! (ptr1+1 is
+                            ; also unchanged in strlen then (important!))
+                            ; -> the original implementation also
+                            ; ignored this case
+
+        sta tmp1            ; tmp1 = strlen of test chars
+        jsr popax           ; get and save s1
+        sta ptr2            ; to ptr2
+        stx ptr2+1
+        ldx #0              ; low counter byte
+        stx tmp2            ; high counter byte
+
+loadChar:
+        ldy #0
+        lda (ptr2),y        ; get next char from s1
+        beq leave           ; handly byte of s1
+advance:
+        inc ptr2            ; advance string position to test
+        bne check
+        inc ptr2+1
+        dey                 ; correct next iny (faster/shorter than bne...)
+
+checkNext:
         iny
-        bne     L3
-
-; The character was not found in s2. Increment the counter and start over
-
-L4:     ldy     tmp3            ; reload index
-        inx
-        bne     L1
-        inc     tmp1
-        bne     L1
+check:  cpy tmp1            ; compare with length of test character string
+        beq endOfTestChars
+        cmp (ptr1),y        ; found matching char?
+        bne checkNext
 
-; The character was found, or we reached the end of s1. Return count of
-; characters
-
-L6:     txa                     ; get low counter byte
-        ldx     tmp1            ; get high counter byte
+leave:  txa                 ; restore position of finding
+        ldx tmp2            ; and return
         rts
 
-
-
-
+endOfTestChars:
+        inx
+        bne loadChar
+        inc tmp2
+        bne loadChar        ; like bra...
index 25cfd06069a53886077ebe07887e66a0d0098a7a..38ea4850e47cec38b257ac169d720afc2ec39e5c 100644 (file)
 size_t __fastcall__ strftime (char* buf, size_t bufsize, const char* format,
                               const struct tm* tm)
 {
-    static const char* days[7] = {
+    static const char* const days[7] = {
         "Sunday",   "Monday", "Tuesday", "Wednesday",
         "Thursday", "Friday", "Saturday"
     };
-    static const char* months[12] = {
+    static const char* const months[12] = {
         "January", "February", "March", "April", "May", "June",
         "July", "August", "September", "October", "November", "December"
     };
index b583eea50c4b1876538af312e90a23a65a99d4fa..1a51edb1174b1ff084d9fe5792e2406b17d8897e 100644 (file)
@@ -1,6 +1,10 @@
 ;
 ; Ullrich von Bassewitz, 31.05.1998
 ;
+; Note: strspn & strcspn call internally this function and rely on
+; the usage of only ptr1 here! Keep in mind when appling changes
+; and check the other implementations too!
+;
 ; int strlen (const char* s);
 ;
 
@@ -23,4 +27,3 @@ L1:     lda     (ptr1),y
 
 L9:     tya                     ; get low byte of counter, hi's all set
         rts
-
index b7bb04b2ad6fd83d56a0c8ceecc2b2a34a5b3538..457e39e2558b88aef1885a167f822760eb4a80aa 100644 (file)
@@ -1,5 +1,6 @@
 ;
 ; Ullrich von Bassewitz, 31.05.1998
+; Christian Krueger: 12-Aug-2013, minor optimizations
 ;
 ; char* strncat (char* dest, const char* src, size_t n);
 ;
@@ -7,66 +8,66 @@
         .export         _strncat
         .import         popax
         .importzp       ptr1, ptr2, ptr3, tmp1, tmp2
-
+        .macpack        cpu
+        
 _strncat:
-        eor     #$FF            ; one's complement to count upwards
-        sta     tmp1
-        txa
-        eor     #$FF
-        sta     tmp2
-        jsr     popax           ; get src
-        sta     ptr1
-        stx     ptr1+1
-        jsr     popax           ; get dest
-        sta     ptr2
-        stx     ptr2+1
-        sta     ptr3            ; remember for function return
-        stx     ptr3+1
-        ldy     #0
+    eor #$FF        ; one's complement to count upwards
+    sta tmp1
+    txa
+    eor #$FF
+    sta tmp2
+    
+    jsr popax       ; get src
+    sta ptr1
+    stx ptr1+1
 
-; find end of dest
+    jsr popax       ; get dest
+    sta ptr3        ; remember for function return
+    stx ptr3+1          
+    stx ptr2+1
+    tay             ; low byte as offset in Y
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+    stz ptr2
+.else
+    ldx #0
+    stx ptr2        ; destination on page boundary
+.endif
 
-L1:     lda     (ptr2),y
-        beq     L2
-        iny
-        bne     L1
-        inc     ptr2+1
-        bne     L1
+; find end of dest
 
-; end found, get offset in y into pointer
+L1: lda (ptr2),y
+    beq L2
+    iny
+    bne L1
+    inc ptr2+1
+    bne L1
 
-L2:     tya
-        clc
-        adc     ptr2
-        sta     ptr2
-        bcc     L3
-        inc     ptr2+1
+; end found, apply offset to dest ptr and reset y
+L2: sty ptr2
 
 ; copy src. We've put the ones complement of the count into the counter, so
 ; we'll increment the counter on top of the loop
 
-L3:     ldy     #0
-        ldx     tmp1            ; low counter byte
+L3: ldy #0
+    ldx tmp1        ; low counter byte
 
-L4:     inx
-        bne     L5
-        inc     tmp2
-        beq     L6              ; jump if done
-L5:     lda     (ptr1),y
-        sta     (ptr2),y
-        beq     L7
-        iny
-        bne     L4
-        inc     ptr1+1
-        inc     ptr2+1
-        bne     L4
+L4: inx
+    bne L5
+    inc tmp2
+    beq L6          ; jump if done
+L5: lda (ptr1),y
+    sta (ptr2),y
+    beq L7
+    iny
+    bne L4
+    inc ptr1+1
+    inc ptr2+1
+    bne L4
 
 ; done, set the trailing zero and return pointer to dest
 
-L6:     lda     #0
-        sta     (ptr2),y
-L7:     lda     ptr3
-        ldx     ptr3+1
-        rts
-
-
+L6: lda #0
+    sta (ptr2),y
+L7: lda ptr3
+    ldx ptr3+1
+    rts
index bd7389e7614762bbf47c78f64c99bf0a92c57750..3e4fb0810beb949fc3a100b436d42f738e14e38a 100644 (file)
@@ -1,47 +1,41 @@
 ;
 ; Ullrich von Bassewitz, 31.05.1998
+; Christian Krueger: 2013-Aug-01, optimization
 ;
 ; char* strrchr (const char* s, int c);
 ;
 
         .export         _strrchr
         .import         popax
-        .importzp       ptr1, ptr2, tmp1
+        .importzp       ptr1, tmp1, tmp2
 
 _strrchr:
-        sta     tmp1            ; Save c
-        jsr     popax           ; get s
-        sta     ptr1
-        stx     ptr1+1
-        lda     #0              ; function result = NULL
-        sta     ptr2
-        sta     ptr2+1
-        tay
-
-L1:     lda     (ptr1),y        ; get next char
-        beq     L3              ; jump if end of string
-        cmp     tmp1            ; found?
-        bne     L2              ; jump if no
-
-; Remember a pointer to the character
-
-        tya
-        clc
-        adc     ptr1
-        sta     ptr2
-        lda     ptr1+1
-        adc     #$00
-        sta     ptr2+1
-
-; Next char
-
-L2:     iny
-        bne     L1
-        inc     ptr1+1
-        bne     L1              ; jump always
-
-; Return the pointer to the last occurrence
-
-L3:     lda     ptr2
-        ldx     ptr2+1
+        sta tmp1        ; Save c
+        jsr popax       ; get s
+        tay             ; low byte to y
+        stx ptr1+1
+        ldx #0          ; default function result is NULL, X is high byte...
+        stx tmp2        ; tmp2 is low-byte
+        stx ptr1        ; low-byte of source string is in Y, so clear real one... 
+   
+testChar:
+        lda (ptr1),y    ; get char
+        beq finished    ; jump if end of string
+        cmp tmp1        ; found?
+        bne nextChar    ; jump if no
+
+charFound:
+        sty tmp2        ; y has low byte of location, save it
+        ldx ptr1+1      ; x holds high-byte of result
+
+nextChar:
+        iny
+        bne testChar
+        inc ptr1+1
+        bne testChar    ; here like bra...
+
+; return the pointer to the last occurrence
+
+finished:
+        lda tmp2        ; high byte in X is already correct...
         rts
index f8b8fff2ac4da37dc8de787e9a31508f0b838162..079b935ee682ea15f85477a2c3c6b1a519a37933 100644 (file)
@@ -1,56 +1,53 @@
 ;
 ; Ullrich von Bassewitz, 11.06.1998
+; Christian Krueger: 08-Aug-2013, optimization
 ;
 ; size_t strspn (const char* s1, const char* s2);
 ;
 
         .export         _strspn
-        .import         popax
-        .importzp       ptr1, ptr2, tmp1, tmp2, tmp3
+        .import         popax, _strlen
+        .importzp       ptr1, ptr2, tmp1, tmp2
 
 _strspn:
-        sta     ptr2            ; Save s2
-        stx     ptr2+1
-        jsr     popax           ; get s1
-        sta     ptr1
-        stx     ptr1+1
-        ldx     #0              ; low counter byte
-        stx     tmp1            ; high counter byte
-        ldy     #$00
-
-L1:     lda     (ptr1),y        ; get next char from s1
-        beq     L6              ; jump if done
-        sta     tmp2            ; save char
-        iny
-        bne     L2
-        inc     ptr1+1
-L2:     sty     tmp3            ; save index into s1
-
-        ldy     #0              ; get index into s2
-L3:     lda     (ptr2),y        ;
-        beq     L6              ; jump if done
-        cmp     tmp2
-        beq     L4
+        jsr _strlen         ; get length in a/x and transfer s2 to ptr1
+                            ; Note: It does not make sense to
+                            ; have more than 255 test chars, so
+                            ; we don't support a high byte here! (ptr1+1 is
+                            ; also unchanged in strlen then (important!))
+                            ; -> the original implementation also
+                            ; ignored this case
+
+        sta tmp1            ; tmp1 = strlen of test chars
+        jsr popax           ; get and save s1
+        sta ptr2            ; to ptr2
+        stx ptr2+1
+        ldx #0              ; low counter byte
+        stx tmp2            ; high counter byte
+
+loadChar:
+        ldy #0
+        lda (ptr2),y        ; get next char from s1
+        beq leave           ; handly byte of s1
+advance:
+        inc ptr2            ; advance string position to test
+        bne check
+        inc ptr2+1
+        dey                 ; correct next iny (faster/shorter than bne...)
+
+checkNext:
         iny
-        bne     L3
+check:  cpy tmp1            ; compare with length of test character string
+        beq leave
+        cmp (ptr1),y        ; found matching char?
+        bne checkNext
 
-; The character was found in s2. Increment the counter and start over
-
-L4:     ldy     tmp3            ; reload index
+foundTestChar:
         inx
-        bne     L1
-        inc     tmp1
-        bne     L1
-
-; The character was not found, or we reached the end of s1. Return count of
-; characters
+        bne loadChar
+        inc tmp2
+        bne loadChar        ; like bra...
 
-L6:     txa                     ; get low counter byte
-        ldx     tmp1            ; get high counter byte
+leave:  txa                 ; restore position of finding
+        ldx tmp2            ; and return
         rts
-
-
-
-
-
-
index c9ca5df7645b7f3f48a2713c89d6cef7590577e2..ef7c65462932806b66939716948187207013d8cb 100644 (file)
@@ -1,8 +1,8 @@
 ;
 ; Ullrich von Bassewitz, 06.08.1998
 ;
-; void cputsxy (unsigned char x, unsigned char y, char* s);
-; void cputs (char* s);
+; void cputsxy (unsigned char x, unsigned char y, const char* s);
+; void cputs (const char* s);
 ;
 
         .export         _cputsxy, _cputs
index 9e723834546c4eb2522f8cdf3733be2e2c2f65b4..3c4856446e54d6b14531816ae8e914e4508f9453 100644 (file)
@@ -18,7 +18,7 @@ _clrscr:
         lda     #$50    ; VRAM offset high ($10 OR $40)
         sta     VDP_CONTROL_W
 
-        lda     #$C0    ; Space from ROM setup
+        lda     #$40    ; Space char from ROM setup
 
         ldx     #0
         ldy     #3
@@ -34,8 +34,8 @@ L1:     sta     VDP_DATA_W
         lda     #0
         sta     CURSOR_X
         sta     CURSOR_Y
-        sta     <SCREEN_PTR
+        sta     SCREEN_PTR
         lda     #$10
-        sta      >SCREEN_PTR
+        sta     SCREEN_PTR+1
 
         rts
index ff60494b9e2d1dc07c4e59a58cd253fc0d509911..437b738b2a3d62ea32fe2e616c8620ed9777ee88 100644 (file)
@@ -96,8 +96,8 @@ BAD_CHAR:
         jmp     plot
 
 ;-----------------------------------------------------------------------------
-; Initialize the conio subsystem. Code goes into the INIT segment, which may
-; be reused after startup.
+; Initialize the conio subsystem. "INIT" segment is nothing special on the
+; Creativision, it is part of the "ROM" memory.
 
 .segment        "INIT"
 
@@ -122,4 +122,4 @@ LL:     lda     boxchars,x
         bne     LL
 
         cli
-        jmp plot
+        jmp     plot
index 6faec38ebf0eee3db4caea7de347822cf363ee48..5185ff237fe979f2dc79e1a8ba060b066fc0fd91 100644 (file)
@@ -31,9 +31,6 @@ entry:
         ldx     #<__RAM_START__ - 1
         txs
 
-        ; Start interrupts
-        cli
-
         ; Clear the BSS data
         jsr     zerobss
 
@@ -49,13 +46,21 @@ entry:
         ; Call module constructors
         jsr     initlib
 
+        ; enable vertical blank interrupts in the display controller
+        lda      #$E0           ; 16K RAM, Active Display, Mode 1, VBI enabled
+        ldx      #$01           ; Register 1
+        jsr      BIOS_WRITE_VDP_REG
+
+        ; Start interrupts
+        cli
+
         ; Call main()
         jsr     callmain
 
         ; Call module destructors. This is also the _exit entry.
 _exit:  jsr     donelib
 
-        ; TODO: Replace with some sort of reset
+        ; A Creativision program isn't supposed to exit.
 loop:   jmp loop
 
 ; ------------------------------------------------------------------------
@@ -81,7 +86,7 @@ irq2:   jmp     BIOS_IRQ2_ADDR
         ; VDP Setup
         ; This sets to Graphics Mode 1
         .byte   $00             ; Register 0
-        .byte   $C0             ; Register 1 16K RAM, Active Display, Mode 1
+        .byte   $C0             ; Register 1 16K RAM, Active Display, Mode 1, VBI disabled
         .byte   $04             ; Register 2 Name Table at $1000 - $12FF
         .byte   $60             ; Register 3 Colour Table at $1800 - $181F
         .byte   $00             ; Register 4 Pattern Table at $0000 - $07FF
index 12ce0abeac95b37cd01cac3e0f2af03038831240..588dd83a01ad705f8a07c3bef8ce6944fbc9f63d 100644 (file)
@@ -1,15 +1,19 @@
 ;
-; Ullrich von Bassewitz, 06.08.1998
+; 1998-08-06, Ullrich von Bassewitz
+; 2017-06-15, Greg King
 ;
 ; void gotoxy (unsigned char x, unsigned char y);
 ;
 
-        .export         _gotoxy
+        .export         gotoxy, _gotoxy
+
         .import         setcursor
         .import         popa
 
         .include        "creativision.inc"
 
+gotoxy: jsr     popa            ; Get Y
+
 .proc   _gotoxy
 
         sta     CURSOR_Y        ; Set Y
index 37b927d08c6fa40497e66cf15c963ca619f830ba..9a5afc42bb4a2e996ace680b1ffb136a004294b7 100644 (file)
@@ -1,60 +1,56 @@
 ;
 ; Standard joystick driver for the Creativision.
 ;
-; Christian Groessler, 2017-02-06
+; Christian Groessler, 2017-03-08
 ;
 
-        .include        "zeropage.inc"
+                .include        "zeropage.inc"
 
-        .include        "joy-kernel.inc"
-        .include        "joy-error.inc"
-        .include        "creativision.inc"
+                .include        "joy-kernel.inc"
+                .include        "joy-error.inc"
+                .include        "creativision.inc"
 
-        .macpack        module
+                .macpack        module
 
 
 ; ------------------------------------------------------------------------
 ; Header. Includes jump table
 
-        module_header   _creativisionstd_joy
+               module_header   _creativisionstd_joy
 
 ; Driver signature
 
-        .byte   $6A, $6F, $79           ; "joy"
-        .byte   JOY_API_VERSION         ; Driver API version number
+                .byte   $6A, $6F, $79           ; "joy"
+                .byte   JOY_API_VERSION         ; Driver API version number
 
 ; Library reference
 
-        .addr   $0000
-
-; Button state masks (8 values)
-
-        .byte   $10                     ; JOY_UP
-        .byte   $04                     ; JOY_DOWN
-        .byte   $20                     ; JOY_LEFT
-        .byte   $08                     ; JOY_RIGHT
-        .byte   $01                     ; JOY_FIRE (button #1)
-        .byte   $02                     ; JOY_FIRE2 (button #2)
-        .byte   $00                     ; Future expansion
-        .byte   $00                     ; Future expansion
+                .addr   $0000
 
 ; Jump table.
 
-        .addr   INSTALL
-        .addr   UNINSTALL
-        .addr   COUNT
-        .addr   READJOY
-        .addr   0                       ; IRQ entry not used
+                .addr   INSTALL
+                .addr   UNINSTALL
+                .addr   COUNT
+                .addr   READJOY
+                .addr   0                       ; IRQ entry not used
 
 ; ------------------------------------------------------------------------
 ; Constants
 
-JOY_COUNT       = 2                     ; Number of joysticks we support
+JOY_COUNT       =       2                       ; Number of joysticks we support
+
+; Symbolic names for joystick masks (similar names like the defines in joystick.h, but not related to them)
+
+JOY_UP          =       $10
+JOY_DOWN        =       $04
+JOY_LEFT        =       $20
+JOY_RIGHT       =       $08
 
 ; ------------------------------------------------------------------------
 ; Code
 
-        .code
+                .code
 
 ; ------------------------------------------------------------------------
 ; INSTALL routine. Is called after the driver is loaded into memory. If
@@ -63,131 +59,180 @@ JOY_COUNT       = 2                     ; Number of joysticks we support
 ; Must return an JOY_ERR_xx code in a/x.
 ;
 
-INSTALL:
-        lda     #JOY_ERR_OK
-        ldx     #0
-;       rts                             ; Fall through
+INSTALL:        lda     #JOY_ERR_OK
+                ldx     #0
+;               rts                             ; Fall through
 
 ; ------------------------------------------------------------------------
 ; UNINSTALL routine. Is called before the driver is removed from memory.
 ; Can do cleanup or whatever. Must not return anything.
 ;
 
-UNINSTALL:
-        rts
+UNINSTALL:      rts
 
 
 ; ------------------------------------------------------------------------
 ; COUNT: Return the total number of available joysticks in a/x.
 ;
 
-COUNT:
-        lda     #<JOY_COUNT
-        ldx     #>JOY_COUNT
-        rts
+COUNT:          lda     #<JOY_COUNT
+                ldx     #>JOY_COUNT
+                rts
 
 ; ------------------------------------------------------------------------
 ; READ: Read a particular joystick passed in A.
 ;
 
-READJOY:
-        and     #1                      ; fix joystick number
-        bne     READJOY_1               ; read right joystick
+READJOY:        and     #1                      ; fix joystick number
+                bne     READJOY_1               ; read right joystick
 
 ; Read left joystick
 
-        ldx     ZP_JOY0_DIR
-        lda     ZP_JOY0_BUTTONS
-        jmp     convert                 ; convert joystick state to sane cc65 values
+                ldx     ZP_JOY0_DIR
+                lda     ZP_JOY0_BUTTONS
+                jmp     convert                 ; convert joystick state to cc65 values
 
 ; Read right joystick
 
-READJOY_1:
-
-        ldx     ZP_JOY1_DIR
-        lda     ZP_JOY1_BUTTONS
-        lsr     a
-        lsr     a
-        ;jmp    convert                 ; convert joystick state to sane cc65 values
-                                        ; fall thru...
+READJOY_1:      ldx     ZP_JOY1_DIR
+                lda     ZP_JOY1_BUTTONS
+                lsr     a
+                lsr     a
+                ;jmp    convert                 ; convert joystick state to cc65 values
+                                                ; fall thru...
 
 ; ------------------------------------------------------------------------
 ; convert: make runtime lib compatible values
-;       A - buttons
-;       X - direction
+;       inputs:
+;               A - buttons
+;               X - direction
 ;
 
 convert:
-        ldy     #0
-        sty     retval                  ; initialize return value
 
 ; ------
 ; buttons:
-        ; Port values are for the left hand joystick (right hand joystick
-        ; values were shifted to the right to be identical).
-        ; Why are there two bits indicating a pressed trigger?
-        ; According to the "Second book of programs for the Dick Smith Wizard"
-        ; (pg. 88ff), the left hand fire button gives the value of
-        ; %00010001 and the right hand button gives %00100010
-        ; Why two bits? Am I missing something? Can there be cases that just
-        ; one of those bits is set?
-        ; We just test if any of those two bits is not zero...
-
-        tay
-        and     #%00010001
-        beq     cnv_1
-
-        inc     retval                  ; left button pressed
-
-cnv_1:  tya
-        and     #%00100010
-        beq     cnv_2
-
-        lda     #$02
-        ora     retval
-        sta     retval                  ; right button pressed
+; Port values are for the left hand joystick (right hand joystick
+; values were shifted to the right to be identical).
+; Why are there two bits indicating a pressed trigger?
+; According to the "Second book of programs for the Dick Smith Wizard"
+; (pg. 88ff), the left hand button gives the value of
+; %00010001 and the right hand button gives %00100010
+; Why two bits? Can there be cases that just one of those bits is set?
+; Until these questions have been answered, we only use the lower two
+; bits and ignore the upper ones...
+
+                and     #%00000011              ; button status came in in A, strip high bits
+                sta     retval                  ; initialize 'retval' with button status
 
 ; ------
 ; direction:
-cnv_2:  txa
-        ; tested with https://sourceforge.net/projects/creativisionemulator
-        ; $49 - %01001001 - up
-        ; $41 - %01000001 - down
-        ; $4D - %01001101 - left
-        ; $45 - %01000101 - right
-        ;
-        ; are these correct? "Second book of programs for the Dick Smith Wizard" pg. 85 says something different
-        ; ignored for now...
-        ; $85 - %10000101 - up + right
-        ; $8D - %10001101 - down + left
-        ; $89 - %10001001 - up + left
-        ; $85 - %10000101 - down + right (emulator bug?)
-
-        bit     testbit                 ; bit #0 set?
-        beq     done                    ; no, no direction
-
-        and     #%00001100              ; mask out other bits
-        lsr     a
-        lsr     a
-        tax
-        lda     #%00000100              ; init bitmask
-loop:   dex
-        bmi     done2
-        asl     a
-        bne     loop
-
-done2:  ora     retval
-        rts
-
-done:   lda     retval
-        rts
+; CV has a 16-direction joystick
+;
+; port values: (compass points)
+; N      -  $49 - %01001001
+; NNE    -  $48 - %01001000
+; NE     -  $47 - %01000111
+; ENE    -  $46 - %01000110
+; E      -  $45 - %01000101
+; ESE    -  $44 - %01000100
+; SE     -  $43 - %01000011
+; SSE    -  $42 - %01000010
+; S      -  $41 - %01000001
+; SSW    -  $40 - %01000000
+; SW     -  $4F - %01001111
+; WSW    -  $4E - %01001110
+; W      -  $4D - %01001101
+; WNW    -  $4C - %01001100
+; NW     -  $4B - %01001011
+; NNW    -  $4A - %01001010
+; center -  $00 - %00000000
+;
+; mapping to cc65 definitions (4-direction joystick with 8 possible directions thru combinations)
+; N, E, S, W            ->      JOY_UP, JOY_RIGHT, JOY_DOWN, JOY_LEFT
+; NE, SE, SW, NW        ->      (JOY_UP | JOY_RIGHT), (JOY_DOWN | JOY_RIGHT), (JOY_DOWN | JOY_LEFT), (JOY_UP | JOY_LEFT)
+; NNE, ENE, ESE, SSE, SSW, WSW, WNW, NNW:
+;  toggle between straight and diagonal direction for every call, e.g.
+;  NNE:
+;    call to READJOY:   return JOY_UP | JOY_RIGHT
+;    call to READJOY:   return JOY_UP
+;    call to READJOY:   return JOY_UP | JOY_RIGHT
+;    call to READJOY:   return JOY_UP
+;    call to READJOY:   return JOY_UP | JOY_RIGHT
+;    etc...
+
+                txa                             ; move direction status into A
+                beq     done                    ; center position (no bits are set), nothing to do
+
+                and     #$0F                    ; get rid of the "$40" bit
+                bit     bit0                    ; is it a "three letter" direction (NNE, ENE, etc.)?
+                beq     special                 ; yes (bit #0 is zero)
+
+                lsr     a                       ; create index into table
+                tax
+                lda     dirtable,x
+done:           ora     retval                  ; include "button" bits
+                ldx     #0
+                rts
+
+; NNE, ENE, ESE, SSE, SSW, WSW, WNW, NNW
+
+special:        lsr     a
+                tax
+
+                lda     toggler                 ; toggle the toggler
+                eor     #$01
+                sta     toggler
+                bne     spec_1                  ; toggler is 1, use spectable_1 entry
+
+                lda     spectable_0,x           ; toggler is 0, use spectable_0 entry
+                bne     done                    ; jump always
+
+spec_1:         lda     spectable_1,x
+                bne     done                    ; jump always
 
 ; ------------------------------------------------------------------------
 ;
-        .data
-testbit:.byte   $01
+                .rodata
+
+                ; a mapping table of "port values" to "cc65 values"
+                ; port value had been shifted one bit to the right (range 0..7)
+dirtable:       .byte   JOY_DOWN                ; S
+                .byte   JOY_DOWN | JOY_RIGHT    ; SE
+                .byte   JOY_RIGHT               ; E
+                .byte   JOY_UP   | JOY_RIGHT    ; NE
+                .byte   JOY_UP                  ; N
+                .byte   JOY_UP   | JOY_LEFT     ; NW
+                .byte   JOY_LEFT                ; W
+                .byte   JOY_DOWN | JOY_LEFT     ; SW
+
+                ; two "special" mapping tables for three-letter directions (NNE, etc.)
+spectable_0:    .byte   JOY_DOWN                ; SSW
+                .byte   JOY_DOWN                ; SSE
+                .byte   JOY_RIGHT               ; ESE
+                .byte   JOY_RIGHT               ; ENE
+                .byte   JOY_RIGHT               ; NNE
+                .byte   JOY_UP                  ; NNW
+                .byte   JOY_LEFT                ; WNW
+                .byte   JOY_LEFT                ; WSW
+
+spectable_1:    .byte   JOY_DOWN | JOY_LEFT     ; SSW
+                .byte   JOY_DOWN | JOY_RIGHT    ; SSE
+                .byte   JOY_DOWN | JOY_RIGHT    ; ESE
+                .byte   JOY_UP   | JOY_RIGHT    ; ENE
+                .byte   JOY_UP   | JOY_RIGHT    ; NNE
+                .byte   JOY_UP   | JOY_LEFT     ; NNW
+                .byte   JOY_UP   | JOY_LEFT     ; WNW
+                .byte   JOY_DOWN | JOY_LEFT     ; WSW
 
 ; ------------------------------------------------------------------------
 ;
-        .bss
-retval: .res    0
+bit0:           .byte   $01
+
+; ------------------------------------------------------------------------
+;
+                .bss
+toggler:        .res    1
+retval:         .res    1
+
+                .end
diff --git a/libsrc/creativision/mainargs.s b/libsrc/creativision/mainargs.s
deleted file mode 100644 (file)
index cda76d8..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-;
-; Ullrich von Bassewitz, 2003-03-07
-;
-; Setup arguments for main
-;
-
-
-        .constructor    initmainargs, 24
-        .import         __argc, __argv
-
-
-;---------------------------------------------------------------------------
-; Get possible command-line arguments. Goes into the special INIT segment,
-; which may be reused after the startup code is run
-
-.segment        "INIT"
-
-.proc   initmainargs
-
-        rts
-
-.endproc
index 8b09484f67cdc4844993d28c74cfaf925d7f8d0d..60b4527996b8c9d19ff70f4146987464feb58b92 100644 (file)
@@ -32,7 +32,7 @@ static char DumpHandler (void);
 static char HelpHandler (void);
 
 /* Forwards for other functions */
-static void DisplayPrompt (char* s);
+static void DisplayPrompt (const char* s);
 static void SingleStep (char StepInto);
 static void RedrawStatic (char  Frame);
 static void Redraw (char Frame);
@@ -166,7 +166,7 @@ extern unsigned      DbgHI;             /* High 16 bit of primary reg */
 typedef struct {
     unsigned char x;
     unsigned char y;
-    char*         text;
+    const char*   text;
 } TextDesc;
 
 /* Window descriptor */
@@ -181,13 +181,13 @@ typedef struct {
     unsigned char fd_visible;           /* Is the window currently visible? */
     char (*fd_func) (void);             /* Handler function */
     unsigned char fd_textcount;         /* Number of text lines to print */
-    TextDesc*     fd_text;              /* Static text in the window */
+    const TextDesc* fd_text;            /* Static text in the window */
 } FrameDesc;
 
 
 
 /* Texts for the windows */
-static TextDesc RegText [] = {
+static const TextDesc RegText [] = {
     { 1,  0, "PC" },
     { 1,  1, "SR" },
     { 1,  2, "A"  },
@@ -197,7 +197,7 @@ static TextDesc RegText [] = {
     { 1,  6, "CS" },
     { 1,  7, "HI" }
 };
-static TextDesc HelpText [] = {
+static const TextDesc HelpText [] = {
     { 1,  0, "F1, ?     Help"                           },
     { 1,  1, "F2, t     Toggle breakpoint"              },
     { 1,  2, "F3, u     Run until subroutine returns"   },
@@ -220,7 +220,7 @@ static TextDesc HelpText [] = {
 
 
 /* Window data */
-static FrameDesc AsmFrame = {
+static const FrameDesc AsmFrame = {
     CH_ULCORNER, CH_TTEE, CH_LTEE, CH_CROSS,
     0, 0, MAX_X - 10, 15,
     MAX_X - 11, 14,
@@ -228,7 +228,7 @@ static FrameDesc AsmFrame = {
     AsmHandler,
     0, 0
 };
-static FrameDesc RegFrame = {
+static const FrameDesc RegFrame = {
     CH_TTEE, CH_URCORNER, CH_LTEE, CH_RTEE,
     MAX_X - 10, 0, MAX_X - 1, 9,
     8, 8,
@@ -236,7 +236,7 @@ static FrameDesc RegFrame = {
     RegHandler,
     sizeof (RegText) / sizeof (RegText [0]), RegText
 };
-static FrameDesc StackFrame = {
+static const FrameDesc StackFrame = {
     CH_LTEE, CH_RTEE, CH_CROSS, CH_RTEE,
     MAX_X - 10, 9, MAX_X - 1, 15,
     8, 5,
@@ -244,7 +244,7 @@ static FrameDesc StackFrame = {
     StackHandler,
     0, 0
 };
-static FrameDesc CStackFrame = {
+static const FrameDesc CStackFrame = {
     CH_CROSS, CH_RTEE, CH_BTEE, CH_LRCORNER,
     MAX_X - 10, 15, MAX_X - 1, MAX_Y - 1,
     8, MAX_Y - 17,
@@ -252,7 +252,7 @@ static FrameDesc CStackFrame = {
     CStackHandler,
     0, 0
 };
-static FrameDesc DumpFrame = {
+static const FrameDesc DumpFrame = {
     CH_LTEE, CH_CROSS, CH_LLCORNER, CH_BTEE,
     0, 15, MAX_X - 10, MAX_Y-1,
     MAX_X - 11, MAX_Y - 17,
@@ -260,7 +260,7 @@ static FrameDesc DumpFrame = {
     DumpHandler,
     0, 0
 };
-static FrameDesc HelpFrame = {
+static const FrameDesc HelpFrame = {
     CH_ULCORNER, CH_URCORNER, CH_LLCORNER, CH_LRCORNER,
     0, 0, MAX_X - 1, MAX_Y-1,
     MAX_X - 2, MAX_Y - 2,
@@ -268,7 +268,7 @@ static FrameDesc HelpFrame = {
     HelpHandler,
     sizeof (HelpText) / sizeof (HelpText [0]), HelpText
 };
-static FrameDesc* Frames [] = {
+static const FrameDesc* const Frames [] = {
     &AsmFrame,
     &RegFrame,
     &StackFrame,
@@ -297,7 +297,7 @@ static unsigned char StackAddr; /* Start address of output */
 
 
 /* Prompt line data */
-static char* ActivePrompt = 0;  /* Last prompt line displayed */
+static const char* ActivePrompt = 0;  /* Last prompt line displayed */
 static char PromptColor;        /* Color behind prompt */
 static char PromptLength;       /* Length of current prompt string */
 
@@ -346,10 +346,10 @@ BreakPoint* DbgIsBreak (unsigned Addr);
 
 
 
-static void DrawFrame (register FrameDesc* F, char Active)
+static void DrawFrame (register const FrameDesc* F, char Active)
 /* Draw one window frame */
 {
-    TextDesc* T;
+    const TextDesc* T;
     unsigned char Count;
     unsigned char tl, tr, bl, br;
     unsigned char x1, y1, width;
@@ -410,7 +410,7 @@ static void DrawFrames (void)
 /* Draw all frames */
 {
     unsigned char I;
-    FrameDesc* F;
+    const FrameDesc* F;
 
     /* Build the frame layout of the screen */
     for (I = 0; I < sizeof (Frames) / sizeof (Frames [0]); ++I) {
@@ -427,7 +427,7 @@ static void ActivateFrame (int Num, unsigned char Clear)
 /* Activate a new frame, deactivate the old one */
 {
     unsigned char y;
-    register FrameDesc* F;
+    register const FrameDesc* F;
 
     if (ActiveFrame != Num) {
 
@@ -462,7 +462,7 @@ static void ActivateFrame (int Num, unsigned char Clear)
 
 
 
-static void DisplayPrompt (char* s)
+static void DisplayPrompt (const char* s)
 /* Display a prompt */
 {
     unsigned char OldColor;
@@ -626,11 +626,11 @@ static char InputHex (char* Prompt, unsigned* Val)
 
 
 
-static void ErrorPrompt (char* Msg)
+static void ErrorPrompt (const char* Msg)
 /* Display an error message and wait for a key */
 {
     /* Save the current prompt */
-    char* OldPrompt = ActivePrompt;
+    const char* OldPrompt = ActivePrompt;
 
     /* Display the new one */
     DisplayPrompt (Msg);
index 4a4871444d934a5fd815f1fc47c32861ad40b962..d49bd2967ee8f7d774541967da94fa47c8fd38ae 100644 (file)
@@ -9,7 +9,7 @@
         .include        "extzp.inc"
 
 gotoxy:
-        jsr     popa            ; Get X
+        jsr     popa            ; Get Y
 
 _gotoxy:
         sta     CURS_Y          ; Set Y
@@ -20,6 +20,4 @@ _gotoxy:
 ;-------------------------------------------------------------------------------
 ; force the init constructor to be imported
 
-        .import initconio
-conio_init      = initconio
-
+        .forceimport    initconio
index 8b18bae7a2099656e70c440f0cd19c5854c7a3b8..d10eb6f413a4a5e75a49506cfa8bb7cc0a86c3c0 100644 (file)
 
         .addr   $0000
 
-; Button state masks (8 values)
-
-        .byte   $01                     ; JOY_UP
-        .byte   $02                     ; JOY_DOWN
-        .byte   $04                     ; JOY_LEFT
-        .byte   $08                     ; JOY_RIGHT
-        .byte   $10                     ; JOY_FIRE_A
-        .byte   $20                     ; JOY_FIRE_B
-        .byte   $80                     ; JOY_SELECT
-        .byte   $40                     ; JOY_START
-
 ; Jump table.
 
         .addr   INSTALL
diff --git a/libsrc/gamate/waitvblank.s b/libsrc/gamate/waitvblank.s
deleted file mode 100644 (file)
index 66686c0..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-;
-; void waitvblank (void);
-;
-
-        .include        "gamate.inc"
-        .include        "extzp.inc"
-
-        .forceimport    ticktock
-        .export         _waitvblank
-
-; FIXME: is this actually correct?
-
-.proc   _waitvblank
-
-        lda     tickcount
-@lp:    cmp     tickcount
-        beq     @lp
-        rts
-
-.endproc
diff --git a/libsrc/gamate/waitvsync.s b/libsrc/gamate/waitvsync.s
new file mode 100644 (file)
index 0000000..dee8340
--- /dev/null
@@ -0,0 +1,22 @@
+;
+; Written by Groepaz <groepaz@gmx.net>
+;
+; void waitvsync (void);
+;
+
+        .include        "gamate.inc"
+        .include        "extzp.inc"
+
+        .forceimport    ticktock
+        .export         _waitvsync
+
+; FIXME: is this actually correct?
+
+.proc   _waitvsync
+
+        lda     tickcount
+@lp:    cmp     tickcount
+        beq     @lp
+        rts
+
+.endproc
index 6afe4609296be4f69e302179068fdbc2de33afc2..2787cb59469feae3694c63af2ce5095a52e419b3 100644 (file)
 
         .addr   $0000
 
-; Button state masks (8 values)
-
-        .byte $01               ; JOY_UP
-        .byte $02               ; JOY_DOWN
-        .byte $04               ; JOY_LEFT
-        .byte $08               ; JOY_RIGHT
-        .byte $10               ; JOY_FIRE
-        .byte $00               ; Future expansion
-        .byte $00               ; Future expansion
-        .byte $00               ; Future expansion
-
 ; Jump table.
 
         .word INSTALL
index 533267be1336b9ec70e6bb4b0766394a3d09f6c2..fd4a5cd118b845725a0f40bed7119d559a1b7a10 100644 (file)
 
 void _mbprintout(void);
 
-static dlgBoxStr _mbdlg_EMPTY = {
+static const dlgBoxStr _mbdlg_EMPTY = {
         DB_DEFPOS(1),
         DB_OPVEC(&RstrFrmDialogue),
         DB_USRROUT(&_mbprintout),
         DB_END,
 };
 
-static dlgBoxStr _mbdlg_OK = {
+static const dlgBoxStr _mbdlg_OK = {
         DB_DEFPOS(1),
         DB_USRROUT(&_mbprintout),
         DB_ICON(OK, DBI_X_1, DBI_Y_2),
         DB_END,
 };
 
-static dlgBoxStr _mbdlg_OKCANCEL = {
+static const dlgBoxStr _mbdlg_OKCANCEL = {
         DB_DEFPOS(1),
         DB_USRROUT(&_mbprintout),
         DB_ICON(OK, DBI_X_0, DBI_Y_2),
@@ -32,7 +32,7 @@ static dlgBoxStr _mbdlg_OKCANCEL = {
         DB_END,
 };
 
-static dlgBoxStr _mbdlg_YESNO = {
+static const dlgBoxStr _mbdlg_YESNO = {
         DB_DEFPOS(1),
         DB_USRROUT(&_mbprintout),
         DB_ICON(YES, DBI_X_0, DBI_Y_2),
@@ -40,7 +40,7 @@ static dlgBoxStr _mbdlg_YESNO = {
         DB_END,
 };
 
-static dlgBoxStr *_mbboxes[] = {
+static const dlgBoxStr * const _mbboxes[] = {
         &_mbdlg_EMPTY,
         &_mbdlg_OK,
         &_mbdlg_OKCANCEL,
index 2b1dcf884158f8d34870bacd7737e14137359096..0746709e9ba132385a4217455d081277a2ada353 100644 (file)
@@ -19,8 +19,6 @@
 .bss
 _joy_drv:       .res    2               ; Pointer to driver
 
-_joy_masks:     .res    .sizeof(JOY_HDR::MASKS)
-
 ; Jump table for the driver functions.
 .data
 joy_vectors:
@@ -65,38 +63,28 @@ _joy_install:
         lda     #>joy_libref
         sta     (ptr1),y
 
-; Copy the mask array
-
-        ldy     #JOY_HDR::MASKS + .sizeof(JOY_HDR::MASKS) - 1
-        ldx     #.sizeof(JOY_HDR::MASKS)-1
-@L1:    lda     (ptr1),y
-        sta     _joy_masks,x
-        dey
-        dex
-        bpl     @L1
-
 ; Copy the jump vectors
 
         ldy     #JOY_HDR::JUMPTAB
         ldx     #0
-@L2:    inx                             ; Skip the JMP opcode
+@L1:    inx                             ; Skip the JMP opcode
         jsr     copy                    ; Copy one byte
         jsr     copy                    ; Copy one byte
         cpy     #(JOY_HDR::JUMPTAB + .sizeof(JOY_HDR::JUMPTAB))
-        bne     @L2
+        bne     @L1
 
         jsr     joy_install             ; Call driver install routine
         tay                             ; Test error code
-        bne     @L3                     ; Bail out if install had errors
+        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     @L3                     ; Jump if vector invalid
+        beq     @L2                     ; Jump if vector invalid
         ldy     #$4C                    ; JMP opcode
         sty     joy_irq                 ; Activate IRQ routine
-@L3:    rts
+@L2:    rts
 
 ; Driver signature invalid
 
index 1146470726760a1a33ec5373b6b220e76169f419..2e91cc43b103cca206f58abb65c30babba972d0a 100644 (file)
 
         .addr   $0000
 
-; Button state masks (8 values)
-
-joy_mask:
-        .byte   $80                     ; JOY_UP
-        .byte   $40                     ; JOY_DOWN
-        .byte   $20                     ; JOY_LEFT
-        .byte   $10                     ; JOY_RIGHT
-        .byte   $01                     ; JOY_FIRE
-        .byte   $02                     ; JOY_FIRE1
-        .byte   $00                     ;
-        .byte   $00                     ;
-
 ; Jump table.
 
         .addr   INSTALL
index b5e653c162e01ee39c05c0265a950d063efad395..3032e9330083bc5f10b43fc0f9781b0ddff5eac0 100644 (file)
 
         .addr   $0000
 
-; Button state masks (8 values)
-
-        .byte   $10                     ; JOY_UP
-        .byte   $20                     ; JOY_DOWN
-        .byte   $40                     ; JOY_LEFT
-        .byte   $80                     ; JOY_RIGHT
-        .byte   $01                     ; JOY_FIRE      (A)
-        .byte   $02                     ; JOY_FIRE2     (B)
-        .byte   $04                     ;               (Select)
-        .byte   $08                     ;               (Start)
-
 ; Jump table.
 
         .addr   INSTALL
diff --git a/libsrc/nes/waitvblank.s b/libsrc/nes/waitvblank.s
deleted file mode 100644 (file)
index 4086469..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-;
-; Written by Groepaz/Hitmen <groepaz@gmx.net>
-; Cleanup by Ullrich von Bassewitz <uz@cc65.org>
-;
-; void waitvblank(void);
-;
-
-        .export _waitvblank
-
-        .include "nes.inc"
-
-.proc   _waitvblank
-
-wait:   lda     PPU_STATUS
-        bpl     wait
-        rts
-
-.endproc
diff --git a/libsrc/nes/waitvsync.s b/libsrc/nes/waitvsync.s
new file mode 100644 (file)
index 0000000..4bdf9a9
--- /dev/null
@@ -0,0 +1,18 @@
+;
+; Written by Groepaz <groepaz@gmx.net>
+; Cleanup by Ullrich von Bassewitz <uz@cc65.org>
+;
+; void waitvsync(void);
+;
+
+        .export _waitvsync
+
+        .include "nes.inc"
+
+.proc   _waitvsync
+
+wait:   lda     PPU_STATUS
+        bpl     wait
+        rts
+
+.endproc
index 9161645c77899bd30334ba5f4adc86f26f34e56c..f05ad33e014c8a1e7e6df55a3abe0a7bb2c24d2f 100644 (file)
@@ -1,50 +1,50 @@
-;\r
-; char cgetc (void);\r
-;\r
-\r
-        .constructor    initcgetc\r
-        .export         _cgetc\r
-        .import         cursor\r
-\r
-        .include        "osic1p.inc"\r
-        .include        "extzp.inc"\r
-        .include        "zeropage.inc"\r
-\r
-; Initialize one-character buffer that is filled by kbhit()\r
-        .segment        "ONCE"\r
-initcgetc:\r
-        lda     #$00\r
-        sta     CHARBUF         ; No character in buffer initially\r
-        rts\r
-\r
-; Input routine from 65V PROM MONITOR, show cursor if enabled\r
-        .code\r
-_cgetc:\r
-        lda     CHARBUF         ; character in buffer available?\r
-        beq     nobuffer\r
-        tax                     ; save character in X\r
-        lda     #$00\r
-        sta     CHARBUF         ; empty buffer\r
-        beq     restorex        ; restore X and return\r
-nobuffer:\r
-        lda     cursor          ; show cursor?\r
-        beq     nocursor\r
-        ldy     CURS_X\r
-        lda     (SCREEN_PTR),y  ; fetch current character\r
-        sta     tmp1            ; save it\r
-        lda     #$A1            ; full white square\r
-        sta     (SCREEN_PTR),y  ; store at cursor position\r
-nocursor:\r
-        jsr     INPUTC          ; get input character in A\r
-        ldx     cursor\r
-        beq     done            ; was cursor on?\r
-        tax                     ; save A in X\r
-        lda     tmp1            ; fetch saved character\r
-        ldy     CURS_X\r
-        sta     (SCREEN_PTR),y  ; store at cursor position\r
-\r
-restorex:\r
-        txa                     ; restore saved character from X\r
-done:\r
-        ldx     #$00            ; high byte of int return value\r
-        rts\r
+;
+; char cgetc (void);
+;
+
+        .constructor    initcgetc
+        .export         _cgetc
+        .import         cursor
+
+        .include        "osic1p.inc"
+        .include        "extzp.inc"
+        .include        "zeropage.inc"
+
+; Initialize one-character buffer that is filled by kbhit()
+        .segment        "ONCE"
+initcgetc:
+        lda     #$00
+        sta     CHARBUF         ; No character in buffer initially
+        rts
+
+; Input routine from 65V PROM MONITOR, show cursor if enabled
+        .code
+_cgetc:
+        lda     CHARBUF         ; character in buffer available?
+        beq     nobuffer
+        tax                     ; save character in X
+        lda     #$00
+        sta     CHARBUF         ; empty buffer
+        beq     restorex        ; restore X and return
+nobuffer:
+        lda     cursor          ; show cursor?
+        beq     nocursor
+        ldy     CURS_X
+        lda     (SCREEN_PTR),y  ; fetch current character
+        sta     tmp1            ; save it
+        lda     #$A1            ; full white square
+        sta     (SCREEN_PTR),y  ; store at cursor position
+nocursor:
+        jsr     INPUTC          ; get input character in A
+        ldx     cursor
+        beq     done            ; was cursor on?
+        tax                     ; save A in X
+        lda     tmp1            ; fetch saved character
+        ldy     CURS_X
+        sta     (SCREEN_PTR),y  ; store at cursor position
+
+restorex:
+        txa                     ; restore saved character from X
+done:
+        ldx     #$00            ; high byte of int return value
+        rts
diff --git a/libsrc/osic1p/doesclrscr.s b/libsrc/osic1p/doesclrscr.s
new file mode 100644 (file)
index 0000000..3d15e8a
--- /dev/null
@@ -0,0 +1,14 @@
+;
+; 2016-06, Christian Groessler
+; 2017-06-26, Greg King
+;
+; unsigned char doesclrscrafterexit (void);
+;
+; Returns 0/1 if, after program termination, the screen isn't/is cleared.
+;
+
+        .import         return1
+
+; cc65's OSI programs return to the monitor ROM which clears the screen.
+
+        .export         _doesclrscrafterexit := return1
index eabeaf79e7ea61cae53ab85ee6adf3180f128f04..aaa03ba6189a05b56ddffdbf0ddbe87b85c29ecf 100644 (file)
@@ -1,4 +1,4 @@
-; Addresses\r
-INPUTC          := $FD00        ; Input character from keyboard\r
-RESET           := $FF00        ; Reset address, show boot prompt\r
-KBD             := $DF00        ; Polled keyboard register\r
+; Addresses
+INPUTC          := $FD00        ; Input character from keyboard
+RESET           := $FF00        ; Reset address, show boot prompt
+KBD             := $DF00        ; Polled keyboard register
index fc832478199a2fd821dd42562c65a7f0ba647fb4..9399d7eee073f11b169dc6d48ea8e77250c812ea 100644 (file)
-;\r
-; Macro definitions for screen layout modules\r
-;\r
-\r
-        .include        "extzp.inc"\r
-        \r
-.linecont +\r
-\r
-;\r
-; Internal function for screensize()\r
-;\r
-.macro  osi_screensize ScrWidth, ScrHeight\r
-                                ; Macro implementation of internal screensize\r
-                                ; function for given width and height in\r
-                                ; characters\r
-                                \r
-        .export         screensize\r
-\r
-.proc   screensize\r
-        ldx     #ScrWidth\r
-        ldy     #ScrHeight\r
-        rts\r
-.endproc\r
-.endmacro\r
-\r
-;\r
-; void clrscr (void);\r
-;\r
-.macro  osi_clrscr ScrBase, ScrRamSize\r
-\r
-        .export         _clrscr\r
-\r
-.proc   _clrscr\r
-        lda     #<ScrBase       ; Fill whole video RAM with blanks by calling\r
-        ldx     #>ScrBase       ; memset appropriately\r
-        jsr     pushax\r
-        \r
-        lda     #' '\r
-        ldx     #$00\r
-        jsr     pushax\r
-        \r
-        lda     #<ScrRamSize\r
-        ldx     #>ScrRamSize\r
-        jsr     _memset\r
-\r
-        lda     #$00            ; Cursor in upper left corner\r
-        sta     CURS_X\r
-        sta     CURS_Y\r
-        \r
-        jmp     plot            ; Set the cursor position\r
-.endproc\r
-\r
-.endmacro\r
-\r
-;\r
-; cputc/cputcxy for Challenger 1P\r
-; Based on PET/CBM implementation\r
-;\r
-\r
-.macro  osi_cputfuncs ScrBase, ScrFirstChar, ScrWidth, ScrHeight, \\r
-                         ScrollDist, ScrLo, ScrHi\r
-\r
-                                ; Number of characters to move for scrolling\r
-                                ; by one line\r
-ScrollLength    = (ScrHeight - 1) * ScrollDist\r
-\r
-;\r
-; void cputcxy (unsigned char x, unsigned char y, char c);\r
-; void cputc (char c);\r
-;\r
-        .export         _cputcxy, _cputc, cputdirect, putchar\r
-        .export         newline, plot\r
-\r
-_cputcxy:\r
-        pha                     ; Save C\r
-        jsr     gotoxy          ; Set cursor, drop x and y\r
-        pla                     ; Restore C\r
-\r
-; Plot a character - also used as internal function\r
-\r
-_cputc: cmp     #$0A            ; CR?\r
-        bne     L1\r
-        lda     #0\r
-        sta     CURS_X\r
-        beq     plot            ; Recalculate pointers\r
-\r
-L1:     cmp     #$0D            ; LF?\r
-        beq     newline         ; Recalculate pointers\r
-\r
-cputdirect:\r
-        jsr     putchar         ; Write the character to the screen\r
-\r
-; Advance cursor position, register Y contains horizontal position after\r
-; putchar\r
-\r
-        cpy     #(ScrWidth - 1) ; Check whether line is full\r
-        bne     L3\r
-        jsr     newline         ; New line\r
-        ldy     #$FF            ; + cr\r
-L3:     iny\r
-        sty     CURS_X\r
-        rts\r
-\r
-newline:\r
-        inc     CURS_Y\r
-        lda     CURS_Y\r
-        cmp     #ScrHeight      ; Screen height\r
-        bne     plot\r
-        dec     CURS_Y          ; Bottom of screen reached, scroll\r
-\r
-                                ; Scroll destination address\r
-        lda     #<(ScrBase + ScrFirstChar)\r
-        ldx     #>(ScrBase + ScrFirstChar)\r
-        jsr     pushax\r
-        \r
-                                ; Scroll source address\r
-        lda     #<(ScrBase + ScrFirstChar + ScrollDist)\r
-        ldx     #>(ScrBase + ScrFirstChar + ScrollDist)\r
-        jsr     pushax\r
-        \r
-                                ; Number of characters to move\r
-        lda     #<ScrollLength\r
-        ldx     #>ScrollLength\r
-        jsr     _memmove\r
-\r
-                                ; Address of first character in last line\r
-                                ; of screen\r
-        lda     #<(ScrBase + ScrFirstChar + ScrollLength)\r
-        sta     ptr1\r
-        lda     #>(ScrBase + ScrFirstChar + ScrollLength)\r
-        sta     ptr1+1\r
-        \r
-        ldy     #ScrWidth       ; Fill last line with blanks\r
-        lda     #' '\r
-clrln:  sta     (ptr1),y\r
-        dey\r
-        bpl     clrln\r
-\r
-plot:   ldy     CURS_Y\r
-        lda     ScrLo,y\r
-        sta     SCREEN_PTR\r
-        lda     ScrHi,y\r
-        sta     SCREEN_PTR+1\r
-        rts\r
-\r
-; Write one character to the screen without doing anything else, return X\r
-; position in register Y\r
-\r
-putchar:\r
-        ldy     CURS_X\r
-        sta     (SCREEN_PTR),y  ; Set char\r
-        rts\r
-        \r
-.endmacro\r
-\r
-.macro osi_screen_funcs ScrBase, ScrRamSize, ScrFirstChar, \\r
-                        ScrWidth, ScrHeight, ScrollDist\r
-\r
-        .import         gotoxy\r
-        .import         _memmove, _memset, pushax\r
-        .importzp       ptr1\r
-\r
-.rodata\r
-\r
-; Screen address tables - offset to real screen\r
-ScrTabLo:\r
-        .repeat ScrHeight, I\r
-        .byte <(ScrBase + ScrFirstChar + I * ScrollDist)\r
-        .endrep\r
-        \r
-ScrTabHi:\r
-        .repeat ScrHeight, I\r
-        .byte >(ScrBase + ScrFirstChar + I * ScrollDist)\r
-        .endrep\r
-\r
-.code\r
-\r
-osi_cputfuncs   ScrBase, ScrFirstChar, ScrWidth, ScrHeight, \\r
-                         ScrollDist, ScrTabLo, ScrTabHi\r
-osi_screensize  ScrWidth, ScrHeight\r
-osi_clrscr      ScrBase, ScrRamSize\r
-\r
+;
+; Macro definitions for screen layout modules
+;
+
+        .include        "extzp.inc"
+        
+.linecont +
+
+;
+; Internal function for screensize()
+;
+.macro  osi_screensize ScrWidth, ScrHeight
+                                ; Macro implementation of internal screensize
+                                ; function for given width and height in
+                                ; characters
+                                
+        .export         screensize
+
+.proc   screensize
+        ldx     #ScrWidth
+        ldy     #ScrHeight
+        rts
+.endproc
+.endmacro
+
+;
+; void clrscr (void);
+;
+.macro  osi_clrscr ScrBase, ScrRamSize
+
+        .export         _clrscr
+
+.proc   _clrscr
+        lda     #<ScrBase       ; Fill whole video RAM with blanks by calling
+        ldx     #>ScrBase       ; memset appropriately
+        jsr     pushax
+        
+        lda     #' '
+        ldx     #$00
+        jsr     pushax
+        
+        lda     #<ScrRamSize
+        ldx     #>ScrRamSize
+        jsr     _memset
+
+        lda     #$00            ; Cursor in upper left corner
+        sta     CURS_X
+        sta     CURS_Y
+        
+        jmp     plot            ; Set the cursor position
+.endproc
+
+.endmacro
+
+;
+; cputc/cputcxy for Challenger 1P
+; Based on PET/CBM implementation
+;
+
+.macro  osi_cputfuncs ScrBase, ScrFirstChar, ScrWidth, ScrHeight, \
+                         ScrollDist, ScrLo, ScrHi
+
+                                ; Number of characters to move for scrolling
+                                ; by one line
+ScrollLength    = (ScrHeight - 1) * ScrollDist
+
+;
+; void cputcxy (unsigned char x, unsigned char y, char c);
+; void cputc (char c);
+;
+        .export         _cputcxy, _cputc, cputdirect, putchar
+        .export         newline, plot
+
+_cputcxy:
+        pha                     ; Save C
+        jsr     gotoxy          ; Set cursor, drop x and y
+        pla                     ; Restore C
+
+; Plot a character - also used as internal function
+
+_cputc: cmp     #$0A            ; CR?
+        bne     L1
+        lda     #0
+        sta     CURS_X
+        beq     plot            ; Recalculate pointers
+
+L1:     cmp     #$0D            ; LF?
+        beq     newline         ; Recalculate pointers
+
+cputdirect:
+        jsr     putchar         ; Write the character to the screen
+
+; Advance cursor position, register Y contains horizontal position after
+; putchar
+
+        cpy     #(ScrWidth - 1) ; Check whether line is full
+        bne     L3
+        jsr     newline         ; New line
+        ldy     #$FF            ; + cr
+L3:     iny
+        sty     CURS_X
+        rts
+
+newline:
+        inc     CURS_Y
+        lda     CURS_Y
+        cmp     #ScrHeight      ; Screen height
+        bne     plot
+        dec     CURS_Y          ; Bottom of screen reached, scroll
+
+                                ; Scroll destination address
+        lda     #<(ScrBase + ScrFirstChar)
+        ldx     #>(ScrBase + ScrFirstChar)
+        jsr     pushax
+        
+                                ; Scroll source address
+        lda     #<(ScrBase + ScrFirstChar + ScrollDist)
+        ldx     #>(ScrBase + ScrFirstChar + ScrollDist)
+        jsr     pushax
+        
+                                ; Number of characters to move
+        lda     #<ScrollLength
+        ldx     #>ScrollLength
+        jsr     _memmove
+
+                                ; Address of first character in last line
+                                ; of screen
+        lda     #<(ScrBase + ScrFirstChar + ScrollLength)
+        sta     ptr1
+        lda     #>(ScrBase + ScrFirstChar + ScrollLength)
+        sta     ptr1+1
+        
+        ldy     #ScrWidth       ; Fill last line with blanks
+        lda     #' '
+clrln:  sta     (ptr1),y
+        dey
+        bpl     clrln
+
+plot:   ldy     CURS_Y
+        lda     ScrLo,y
+        sta     SCREEN_PTR
+        lda     ScrHi,y
+        sta     SCREEN_PTR+1
+        rts
+
+; Write one character to the screen without doing anything else, return X
+; position in register Y
+
+putchar:
+        ldy     CURS_X
+        sta     (SCREEN_PTR),y  ; Set char
+        rts
+        
+.endmacro
+
+.macro osi_screen_funcs ScrBase, ScrRamSize, ScrFirstChar, \
+                        ScrWidth, ScrHeight, ScrollDist
+
+        .import         gotoxy
+        .import         _memmove, _memset, pushax
+        .importzp       ptr1
+
+.rodata
+
+; Screen address tables - offset to real screen
+ScrTabLo:
+        .repeat ScrHeight, I
+        .byte <(ScrBase + ScrFirstChar + I * ScrollDist)
+        .endrep
+        
+ScrTabHi:
+        .repeat ScrHeight, I
+        .byte >(ScrBase + ScrFirstChar + I * ScrollDist)
+        .endrep
+
+.code
+
+osi_cputfuncs   ScrBase, ScrFirstChar, ScrWidth, ScrHeight, \
+                         ScrollDist, ScrTabLo, ScrTabHi
+osi_screensize  ScrWidth, ScrHeight
+osi_clrscr      ScrBase, ScrRamSize
+
 .endmacro
\ No newline at end of file
diff --git a/libsrc/osic1p/revers.s b/libsrc/osic1p/revers.s
new file mode 100644 (file)
index 0000000..bb178f6
--- /dev/null
@@ -0,0 +1,9 @@
+;
+; 2017-06-26, Greg King
+;
+; unsigned char __fastcall__ revers (unsigned char onoff)
+;
+
+        .import         return0
+
+        .export         _revers := return0      ; no attribute
index 746929dd258ed5b8e6109b8d18f9775843651a1a..ab25134ddfe4eb3fa6ce3738e35f2d408906a9f5 100644 (file)
 
         .addr   $0000
 
-; Button state masks (8 values)
-
-        .byte   $10                     ; JOY_UP
-        .byte   $40                     ; JOY_DOWN
-        .byte   $80                     ; JOY_LEFT
-        .byte   $20                     ; JOY_RIGHT
-        .byte   $01                     ; JOY_FIRE_A
-        .byte   $02                     ; JOY_FIRE_B
-        .byte   $04                     ; JOY_SELECT
-        .byte   $08                     ; JOY_RUN
-
 ; Jump table.
 
         .addr   INSTALL
diff --git a/libsrc/pce/waitvblank.s b/libsrc/pce/waitvblank.s
deleted file mode 100644 (file)
index b9f0f90..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-;
-; void waitvblank (void);
-;
-
-        .include        "pce.inc"
-        .include        "extzp.inc"
-
-        .forceimport    ticktock
-        .export         _waitvblank
-
-.proc   _waitvblank
-
-        lda     tickcount
-@lp:    cmp     tickcount
-        beq     @lp
-        rts
-
-.endproc
diff --git a/libsrc/pce/waitvsync.s b/libsrc/pce/waitvsync.s
new file mode 100644 (file)
index 0000000..c6435da
--- /dev/null
@@ -0,0 +1,20 @@
+;
+; Written by Groepaz <groepaz@gmx.net>
+;
+; void waitvsync (void);
+;
+
+        .include        "pce.inc"
+        .include        "extzp.inc"
+
+        .forceimport    ticktock
+        .export         _waitvsync
+
+.proc   _waitvsync
+
+        lda     tickcount
+@lp:    cmp     tickcount
+        beq     @lp
+        rts
+
+.endproc
index 229055fcb75d08ac28e4a97556ad90b5f2e09cce..3bb36835576dd9880d5fe9602a7a3b9b902c8aba 100644 (file)
 
         .addr   $0000
 
-; Button state masks (8 values)
-
-        .byte   $01                     ; JOY_UP
-        .byte   $02                     ; JOY_DOWN
-        .byte   $04                     ; JOY_LEFT
-        .byte   $08                     ; JOY_RIGHT
-        .byte   $10                     ; JOY_FIRE
-        .byte   $00                     ; JOY_FIRE2 unavailable
-        .byte   $00                     ; Future expansion
-        .byte   $00                     ; Future expansion
-
 ; Jump table.
 
         .addr   INSTALL
index 5847c2b094f44773a4a991f34ceacbc95c66ef0f..29c6de627c48db49ff0d157c0fa2e2173f8916a0 100644 (file)
 
         .addr   $0000
 
-; Button state masks (8 values)
-
-        .byte   $01             ; JOY_UP
-        .byte   $02             ; JOY_DOWN
-        .byte   $04             ; JOY_LEFT
-        .byte   $08             ; JOY_RIGHT
-        .byte   $10             ; JOY_FIRE
-        .byte   $00             ; JOY_FIRE2 unavailable
-        .byte   $00             ; Future expansion
-        .byte   $00             ; Future expansion
-
 ; Jump table.
 
         .addr   INSTALL
diff --git a/libsrc/pet/kbrepeat.s b/libsrc/pet/kbrepeat.s
new file mode 100644 (file)
index 0000000..100d850
--- /dev/null
@@ -0,0 +1,29 @@
+;
+; unsigned char __fastcall__ kbrepeat (unsigned char mode);
+;
+; 2017-06-16, Groepaz
+; 2017-09-05, Greg King
+;
+
+        .export         _kbrepeat
+
+        .include        "pet.inc"
+
+_kbrepeat:
+        ldx     #>$0000
+        ldy     SCR_LINELEN
+        cpy     #40 + 1
+        bcc     L1              ; branch if screen is 40 columns wide
+
+        ldy     KBDREPEAT80     ; get old value
+        sta     KBDREPEAT80     ; store new value
+        tya                     ; return old value
+        rts
+
+L1:     tay
+        lda     KBDREPEAT40B    ; get REPEAT-key flag (used by some editor ROMs)
+        lsr     a               ; move bit 0 into bit 7
+        ror     a
+        ora     KBDREPEAT40     ; combine with old key-REPEAT flags
+        sty     KBDREPEAT40
+        rts
index 4a51328877e7277e20029723bfb0c58ca42b441d..d998b2699057f832e3fabb9fd15b88488e54f37f 100644 (file)
 
         .addr   $0000
 
-; Button state masks (8 values)
-
-        .byte   $01                     ; JOY_UP
-        .byte   $02                     ; JOY_DOWN
-        .byte   $04                     ; JOY_LEFT
-        .byte   $08                     ; JOY_RIGHT
-        .byte   $80                     ; JOY_FIRE
-        .byte   $00                     ; JOY_FIRE2 unavailable
-        .byte   $00                     ; Future expansion
-        .byte   $00                     ; Future expansion
-
 ; Jump table.
 
         .addr   INSTALL
@@ -107,7 +96,7 @@ READ:   ldy     #%11111011      ; Load index for joystick #1
         cli
         eor     #%11111111
 
-; The fire buttons are in bits 6 and 7.  Both of them cannot be %1 together.
+; The push buttons are in bits 6 and 7.  Both of them cannot be %1 together.
 ; Therefore, bit 6 can be merged with bit 7.
 
         clc
diff --git a/libsrc/plus4/kbrepeat.s b/libsrc/plus4/kbrepeat.s
new file mode 100644 (file)
index 0000000..9c0dc68
--- /dev/null
@@ -0,0 +1,14 @@
+;
+; unsigned char __fastcall__ kbrepeat (unsigned char mode);
+;
+
+        .export _kbrepeat
+
+        .include        "plus4.inc"
+
+_kbrepeat:
+        ldx KBDREPEAT           ; get old value
+        sta KBDREPEAT           ; store new value
+        txa                     ; return old value
+        ldx #0
+        rts
diff --git a/libsrc/plus4/waitvsync.s b/libsrc/plus4/waitvsync.s
new file mode 100644 (file)
index 0000000..32b81b5
--- /dev/null
@@ -0,0 +1,17 @@
+;
+; Written by Groepaz <groepaz@gmx.net>
+;
+; void waitvsync (void);
+;
+
+        .export         _waitvsync
+
+        .include        "plus4.inc"
+
+_waitvsync:
+@l1:
+        lda     TED_VLINEHI
+        and     #$01
+        ora     TED_VLINELO
+        bne     @l1
+        rts
index 6fb2dacf7ee48b70d49453e410476ac63a0b61f1..e644671c0eb23a8acf93f44b508ede46141243eb 100644 (file)
@@ -1,5 +1,6 @@
 ;
 ; Ullrich von Bassewitz, 05.08.1998
+; Christian Krueger, 11-Mar-2017, spend two bytes for one cycle, improved 65SC02 optimization
 ;
 ; CC65 runtime: add ints
 ;
@@ -8,32 +9,46 @@
 ; called a lot!
 
         .export         tosadda0, tosaddax
-        .importzp       sp
+        .importzp       sp, tmp1
 
         .macpack        cpu
 
 tosadda0:
         ldx     #0
 tosaddax:
-        clc
-.if (.cpu .bitand CPU_ISET_65SC02)
-        adc     (sp)            ; 65SC02 version - saves 2 cycles
-        ldy     #1
-.else
-        ldy     #0
-        adc     (sp),y          ; lo byte
-        iny
-.endif
-        pha                     ; save it
-        txa
-        adc     (sp),y          ; hi byte
-        tax
-        clc
-        lda     sp
-        adc     #2
-        sta     sp
-        bcc     L1
-        inc     sp+1
-L1:     pla                     ; Restore low byte
-        rts
+        clc                     ; (2)
+
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+
+        adc     (sp)            ; (7)
+        tay                     ; (9)
+        inc     sp              ; (14)
+        bne     hiadd           ; (17)
+        inc     sp+1            ; (-1+5)
+hiadd:  txa                     ; (19)
+        adc     (sp)            ; (24)
+        tax                     ; (26)
+        inc     sp              ; (31)
+        bne     done            ; (34)
+        inc     sp+1            ; (-1+5)
+done:   tya                     ; (36)
 
+.else        
+
+        ldy     #0              ; (4)
+        adc     (sp),y          ; (9) lo byte
+        iny                     ; (11)
+        sta     tmp1            ; (14) save it
+        txa                     ; (16) 
+        adc     (sp),y          ; (21) hi byte
+        tax                     ; (23)
+        clc                     ; (25)
+        lda     sp              ; (28)
+        adc     #2              ; (30)
+        sta     sp              ; (33)
+        bcc     L1              ; (36)
+        inc     sp+1            ; (-1+5)
+L1:     lda     tmp1            ; (39) restore low byte
+
+.endif
+        rts                     ; (6502: 45 cycles, 26 bytes <-> 65SC02: 42 cycles, 22 bytes )
index 661b3124a871f807dd85caac0f5120f041d53efa..bd3462915bb8c36347056a1cf647dd08fdde1dce 100644 (file)
@@ -1,5 +1,6 @@
 ;
 ; Ullrich von Bassewitz, 23.11.2002
+; Christian Krueger, 11-Mar-2017, saved 5 bytes
 ;
 ; CC65 runtime: Convert char in ax into a long
 ;
 
 ; Convert A from char to long in EAX
 
-aulong: ldx     #0
-        stx     sreg
-        stx     sreg+1
-        rts
+along:  ldx     #$ff
+        cmp     #$80            ; Positive?
+        bcs     store           ; no, apply $FF
 
-along:  cmp     #$80            ; Positive?
-        bcc     aulong          ; Yes, handle like unsigned type
-        ldx     #$ff
-        stx     sreg
+aulong: ldx     #0
+store:  stx     sreg
         stx     sreg+1
         rts
-
-
index 6d97b5025bf885895e734e8f5a1ca9168056d18b..1fbd53ef0c8bea1b6e7fd63554329030da00fa93 100644 (file)
@@ -1,5 +1,6 @@
 ;
 ; Ullrich von Bassewitz, 25.10.2000
+; Christian Krueger, 02-Mar-2017, some bytes saved
 ;
 ; CC65 runtime: Convert int in ax into a long
 ;
 
 ; Convert AX from int to long in EAX
 
+axlong: ldy     #$ff
+        cpx     #$80            ; Positive?
+        bcs     store           ; No, apply $FF
+
 axulong:
         ldy     #0
-        sty     sreg
-        sty     sreg+1
-        rts
-
-axlong: cpx     #$80            ; Positive?
-        bcc     axulong         ; Yes, handle like unsigned type
-        ldy     #$ff
-        sty     sreg
+store:  sty     sreg
         sty     sreg+1
         rts
-
-
-
diff --git a/libsrc/runtime/callptr4.s b/libsrc/runtime/callptr4.s
new file mode 100644 (file)
index 0000000..9a15609
--- /dev/null
@@ -0,0 +1,10 @@
+;
+; CC65 runtime: call function via pointer in ptr4
+;
+
+        .export         callptr4
+        .importzp       ptr4
+
+callptr4:
+        jmp     (ptr4)          ; jump there
+
index 2632ec90940ea932742401718d0f3139fc99ce0f..57bec0629827c1b6b89bc62d2926cd0768ce679d 100644 (file)
@@ -1,5 +1,6 @@
 ;
 ; Ullrich von Bassewitz, 07.04.2000
+; Christian Krueger, 12-Mar-2017, added 65SC02 optimization
 ;
 ; CC65 runtime: += operator
 ;
@@ -10,6 +11,7 @@
         .export         laddeq1, laddeqa, laddeq
         .importzp       sreg, ptr1, tmp1
 
+        .macpack        cpu
 
 laddeq1:
         lda     #$01
@@ -20,14 +22,20 @@ laddeqa:
         stx     sreg+1
 
 laddeq: sty     ptr1+1                  ; Store high byte of address
-        ldy     #$00                    ; Address low byte
         clc
 
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+        adc     (ptr1)
+        sta     (ptr1)
+        ldy     #$01                    ; Address byte 1
+.else
+        ldy     #$00                    ; Address low byte
         adc     (ptr1),y
         sta     (ptr1),y
+        iny                             ; Address byte 1
+.endif
         pha                             ; Save byte 0 of result for later
 
-        iny                             ; Address byte 1
         txa
         adc     (ptr1),y                ; Load byte 1
         sta     (ptr1),y
index 506c071a4f18e98db034054b5763675accf73614..6ea4e5bcb29fda011f072ace64778ac03b0b90bb 100644 (file)
@@ -1,5 +1,6 @@
 ;
 ; Ullrich von Bassewitz, 06.08.1998
+; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
 ;
 ; CC65 runtime: and on longs
 ;
@@ -8,17 +9,28 @@
         .import         addysp1
         .importzp       sp, sreg, tmp1
 
+        .macpack        cpu
                                    
 tosand0ax:
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+        stz     sreg
+        stz     sreg+1
+.else
         ldy     #$00
         sty     sreg
         sty     sreg+1
+.endif  
 
 tosandeax:
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+        and     (sp)            ; byte 0
+        ldy     #1
+.else
         ldy     #0
         and     (sp),y          ; byte 0
-        sta     tmp1
         iny
+.endif        
+        sta     tmp1
         txa
         and     (sp),y          ; byte 1
         tax
index 8f4e055f563a5b301b4d9ca05fd993581bc1c97a..4a9ff799493d70c1e37ca722ee7fbd679e60190c 100644 (file)
@@ -1,5 +1,6 @@
 ;  
 ; Ullrich von Bassewitz, 06.08.1998
+; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
 ;
 ; CC65 runtime: function epilogue
 ;
@@ -13,6 +14,8 @@
         .import         addysp
         .importzp       sp
 
+        .macpack        cpu
+
 leave00:
         lda     #0
 leave0: ldx     #0
@@ -24,6 +27,20 @@ leavey0:
         ldx     #0              ; return < 256
 leavey:
         jsr     addysp          ; drop stack frame
+
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+
+leave:  tay                     ; save A a sec
+        lda     (sp)            ; that's the pushed arg size
+        sec                     ; Count the byte, the count's stored in
+        adc     sp
+        sta     sp
+        bcc     L1
+        inc     sp+1
+L1:     tya                     ; Get return value back
+
+.else
+
 leave:  pha                     ; save A a sec
         ldy     #0
         lda     (sp),y          ; that's the pushed arg size
@@ -33,5 +50,7 @@ leave:  pha                     ; save A a sec
         bcc     L1
         inc     sp+1
 L1:     pla                     ; Get return value back
+
+.endif
         rts
 
index 74deb23f08343920c2de9cb1c15f208ccd591cb8..caeb0c4f64b856d9b9a1b29cbe9f3821a526dbe0 100644 (file)
@@ -1,6 +1,6 @@
 ;
 ; Ullrich von Bassewitz, 07.08.1998
-;
+; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
 ; CC65 runtime: modulo operation for long signed ints
 ;
 
         .import         poplsargs, udiv32, negeax
         .importzp       sreg, ptr1, ptr2, tmp1, tmp3, tmp4
 
+        .macpack        cpu
+
 tosmod0ax:
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+        stz     sreg
+        stz     sreg+1
+.else
         ldy     #$00
         sty     sreg
         sty     sreg+1
+.endif
 
 tosmodeax:                         
         jsr     poplsargs       ; Get arguments from stack, adjust sign
index 7ad2b2aa4266f39eb2df17241656f2c457685b16..860d58cba4b2161d92c2b24828a684676ddf01f1 100644 (file)
@@ -1,5 +1,6 @@
 ;
 ; Ullrich von Bassewitz, 13.08.1998
+; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
 ;
 ; CC65 runtime: multiplication for long (unsigned) ints
 ;
@@ -8,20 +9,32 @@
         .import         addysp1
         .importzp       sp, sreg, tmp1, tmp2, tmp3, tmp4, ptr1, ptr3, ptr4
 
+        .macpack        cpu
+
 tosmul0ax:
 tosumul0ax:
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+        stz     sreg
+        stz     sreg+1
+.else
         ldy     #$00    
         sty     sreg
         sty     sreg+1
+.endif        
 
 tosmuleax:
 tosumuleax:
 mul32:  sta     ptr1
         stx     ptr1+1          ; op2 now in ptr1/sreg
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+        lda     (sp)
+        ldy     #1
+.else        
         ldy     #0
         lda     (sp),y
-        sta     ptr3
         iny
+.endif
+        sta     ptr3
         lda     (sp),y
         sta     ptr3+1
         iny
index a74b3305950acb1b55d3e55e06dc3af98baeedaa..94ab3c890178beb24efe2ba6f564a9da0d4a94bc 100644 (file)
@@ -1,5 +1,6 @@
 ;
 ; Ullrich von Bassewitz, 06.08.1998
+; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
 ;
 ; CC65 runtime: or on longs
 ;
@@ -8,17 +9,28 @@
         .import         addysp1
         .importzp       sp, sreg, tmp1
                                   
+        .macpack        cpu
 
 tosor0ax:
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+        stz     sreg
+        stz     sreg+1
+.else
         ldy     #$00
         sty     sreg
-        sty     sreg+1 
+        sty     sreg+1
+.endif  
 
 tosoreax:
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+        ora     (sp)
+        ldy     #1
+.else
         ldy     #0
         ora     (sp),y          ; byte 0
-        sta     tmp1
         iny
+.endif        
+        sta     tmp1
         txa
         ora     (sp),y          ; byte 1
         tax
index 7d281db52e1b581c240ba0d13e52f4812a1146c9..ffff5ffc10f8fe6802ba93d2d2c12c7ef6937458 100644 (file)
@@ -1,5 +1,6 @@
 ;
 ; Ullrich von Bassewitz, 29.12.1999
+; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
 ;
 ; CC65 runtime: long pop
 ;
@@ -8,6 +9,7 @@
         .import         incsp4
         .importzp       sp, sreg
 
+        .macpack        cpu
 
 popeax: ldy     #3
         lda     (sp),y
@@ -18,8 +20,12 @@ popeax: ldy     #3
         dey
         lda     (sp),y
         tax
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+        lda     (sp)
+.else        
         dey
         lda     (sp),y
+.endif
         jmp     incsp4
 
 
index 074b4320aee1a5bbeee5924e9eef25043c207584..4fed77f05bf590047b15ee27c71231c1e67d6b7a 100644 (file)
@@ -1,5 +1,6 @@
 ;
 ; Ullrich von Bassewitz, 06.08.1998
+; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
 ;
 ; CC65 runtime: long push
 ;
         .import         decsp4
         .importzp       sp, sreg
 
+        .macpack        cpu
+
 pushl0:
         lda     #0
         tax
 push0ax:
-        ldy     #0
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+        stz     sreg
+        stz     sreg+1
+.else
+        ldy     #$00
         sty     sreg
         sty     sreg+1
+.endif
 pusheax:
         pha                     ; decsp will destroy A (but not X)
         jsr     decsp4
@@ -30,8 +38,12 @@ pusheax:
         dey
         txa
         sta     (sp),y
-        dey
         pla
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+        sta     (sp)
+.else        
+        dey
         sta     (sp),y
+.endif        
         rts
 
index fd519ca4f742f7cdd61b8312ffec6d69ef9a5dc8..928164f4061c3da0babbf1f32578f1f315d924aa 100644 (file)
@@ -1,5 +1,6 @@
 ;
 ; Ullrich von Bassewitz, 05.08.1998
+; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
 ;
 ; CC65 runtime: long sub reversed
 ;
         .import         addysp1
         .importzp       sp, sreg, tmp1
 
+        .macpack        cpu
+
 tosrsub0ax:
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+        stz     sreg
+        stz     sreg+1
+.else
         ldy     #$00
         sty     sreg
         sty     sreg+1
+.endif
 
-tosrsubeax:                         
-        ldy     #0
+tosrsubeax:
         sec
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+        sbc     (sp)
+        ldy     #1
+.else                         
+        ldy     #0
         sbc     (sp),y          ; byte 0
+        iny
+.endif
         sta     tmp1            ; use as temp storage
         txa
-        iny
         sbc     (sp),y          ; byte 1
         tax
         iny
index fa21e463ec0ee3805081583248dd5eb7a255d8fe..d5f4c45b3783d7cb751f7aced6d051119f61cba8 100644 (file)
@@ -1,7 +1,8 @@
 ;
 ; Ullrich von Bassewitz, 08.08.1998
+; Christian Krueger, 11-Mar-2017, optimization
 ;
-; CC65 runtime: save ax into temp storage/restore ax from temp storage
+; CC65 runtime: save eax into temp storage/restore eax from temp storage
 ;
 
         .export         saveeax, resteax
 saveeax:
         sta     regsave
         stx     regsave+1
-        lda     sreg
-        sta     regsave+2
-        lda     sreg+1
-        sta     regsave+3
-        lda     regsave
+        ldy     sreg
+        sty     regsave+2
+        ldy     sreg+1
+        sty     regsave+3
         rts
 
 resteax:
@@ -25,4 +25,3 @@ resteax:
         ldx     regsave+1
         lda     regsave
         rts
-
index 926d52e510f0babfe9695025e303524c75853c5b..6f80491cacaa491d3daa68adc4978d20e19bd74c 100644 (file)
@@ -1,6 +1,6 @@
 ;
 ; Ullrich von Bassewitz, 05.08.1998
-;
+; Christian Krueger, 11-Mar-2017, Ã­mproved  65SC02 optimization
 ; CC65 runtime: long sub
 ;
 
         .macpack        cpu
 
 tossub0ax:
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+        stz     sreg
+        stz     sreg+1
+.else
         ldy     #$00
         sty     sreg
         sty     sreg+1
+.endif  
 
 tossubeax:
         sec
         eor     #$FF
-.if (.cpu .bitand CPU_ISET_65SC02)
+.if (.cpu .bitand ::CPU_ISET_65SC02)
         adc     (sp)            ; 65SC02 version - saves 2 cycles
         ldy     #1
 .else
index 9f5853d29f4e66be62627dbfc401823ee02194eb..5e3d25783375329749b6c6d415600b750398a4d0 100644 (file)
@@ -1,5 +1,6 @@
 ;                                 
 ; Ullrich von Bassewitz, 07.04.2000
+; Christian Krueger, 12-Mar-2017, added 65SC02 optimization
 ;
 ; CC65 runtime: -= operator
 ;
@@ -10,6 +11,7 @@
         .export         lsubeq1, lsubeqa, lsubeq
         .importzp       sreg, ptr1
 
+        .macpack        cpu
 
 lsubeq1:
         lda     #$01
@@ -20,15 +22,20 @@ lsubeqa:
         stx     sreg+1
 
 lsubeq: sty     ptr1+1                  ; Store high byte of address
-        ldy     #$00                    ; Address low byte
+    
         sec
-
         eor     #$FF
+ .if (.cpu .bitand ::CPU_ISET_65SC02)
+        adc     (ptr1)                  ; Subtract byte 0
+        sta     (ptr1)
+        ldy     #$01                    ; Address byte 1               
+ .else
+        ldy     #$00                    ; Address low byte
         adc     (ptr1),y                ; Subtract byte 0
         sta     (ptr1),y
+        iny                             ; Address byte 1       
+ .endif  
         pha                             ; Save byte 0 of result for later
-
-        iny                             ; Address byte 1
         txa
         eor     #$FF
         adc     (ptr1),y                ; Subtract byte 1
index 149c98a7875e62ce790da91deee6df3389381c09..54af4780e4407b74bf0e464fe366dfc1e1a4e06c 100644 (file)
@@ -1,5 +1,6 @@
 ;
 ; Ullrich von Bassewitz, 17.08.1998
+; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
 ;
 ; CC65 runtime: division for long unsigned ints
 ;
@@ -8,10 +9,17 @@
         .import         addysp1
         .importzp       sp, sreg, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4
 
+        .macpack        cpu
+
 tosudiv0ax:
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+        stz     sreg
+        stz     sreg+1
+.else
         ldy     #$00
         sty     sreg
         sty     sreg+1
+.endif
 
 tosudiveax:                         
         jsr     getlop          ; Get the paramameters
@@ -30,10 +38,15 @@ getlop: sta     ptr3            ; Put right operand in place
         lda     sreg+1
         sta     ptr4+1
 
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+        lda     (sp)
+        ldy     #1
+.else
         ldy     #0              ; Put left operand in place
         lda     (sp),y
-        sta     ptr1
         iny
+.endif
+        sta     ptr1
         lda     (sp),y
         sta     ptr1+1
         iny
index e290e11677e9a0a2e9a2e862a773ad59d93e11bb..241801a90bf15d51a53f0f13340ced5ccd947ee5 100644 (file)
@@ -1,5 +1,6 @@
 ;
 ; Ullrich von Bassewitz, 27.09.1998
+; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
 ;
 ; CC65 runtime: modulo operation for long unsigned ints
 ;
@@ -8,10 +9,17 @@
         .import         getlop, udiv32
         .importzp       sreg, tmp3, tmp4, ptr2
 
+        .macpack        cpu
+
 tosumod0ax:                          
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+        stz     sreg
+        stz     sreg+1
+.else
         ldy     #$00
         sty     sreg
         sty     sreg+1
+.endif
 
 tosumodeax:
         jsr     getlop          ; Get the paramameters
index ce21ef35bd7dfcfdbcb3091e1755442f17c91743..4ec9a41297db8343fe45fefbc120742d895f3570 100644 (file)
@@ -1,5 +1,6 @@
 ;
 ; Ullrich von Bassewitz, 06.08.1998
+; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
 ;
 ; CC65 runtime: xor on longs
 ;
@@ -8,16 +9,28 @@
         .import         addysp1
         .importzp       sp, sreg, tmp1
 
+        .macpack        cpu
+
 tosxor0ax:
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+        stz     sreg
+        stz     sreg+1
+.else
         ldy     #$00
         sty     sreg
         sty     sreg+1
+.endif
 
-tosxoreax:                         
+tosxoreax:
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+        eor     (sp)            ; byte 0
+        ldy     #1
+.else                         
         ldy     #0
         eor     (sp),y          ; byte 0
-        sta     tmp1
         iny
+.endif
+        sta     tmp1
         txa
         eor     (sp),y          ; byte 1
         tax
index a15b24b9335dee4acc1a1aedc5de7ba1c440e38f..643f418aa6cbc03fd39e28b160c802d6a58ca5e9 100644 (file)
@@ -1,5 +1,6 @@
 ;
 ; Ullrich von Bassewitz, 05.10.1998
+; Christian Krueger, 11-Mar-2017, optimization
 ;
 ; CC65 runtime: Make boolean according to flags
 ;
 
 
 boolne: bne     ret1
-        ldx     #$00
+ret0:   ldx     #$00
         txa
         rts
 
 
-booleq: beq     ret1
-        ldx     #$00
-        txa
+booleq: bne     ret0
+ret1:   ldx     #$00
+        lda     #$01
         rts
 
 
@@ -44,17 +45,9 @@ boolult:
 
 
 boolugt:
-        beq     L1
+        beq     ret0
 booluge:
-        bcs     ret1
-L1:     ldx     #$00
+        ldx     #$00
         txa
+        rol     a
         rts
-
-
-ret1:   ldx     #$00
-        lda     #$01
-        rts
-
-
-
index 8570c0cd7adb378da9cfcc301c83b717b8739632..1c2c4125e61acc3dbcd1784e334c2c18e635a3ae 100644 (file)
@@ -1,5 +1,6 @@
 ;
 ; Ullrich von Bassewitz, 05.08.1998
+; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
 ;
 ; CC65 runtime: or on ints
 ;
@@ -8,13 +9,20 @@
         .import         addysp1
         .importzp       sp, tmp1
 
+        .macpack        cpu
+
 tosora0:
         ldx     #$00
 tosorax:
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+        ora     (sp)
+        ldy     #1
+.else
         ldy     #0
         ora     (sp),y
-        sta     tmp1
         iny
+.endif        
+        sta     tmp1
         txa
         ora     (sp),y
         tax
index 475a69e767e0f196ba4d8dc6fe3aeb47e29b9286..69ee6da2232323dec26bc5edb61ba142ebcfb437 100644 (file)
@@ -1,5 +1,6 @@
 ;
 ; Ullrich von Bassewitz, 05.08.1998
+; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
 ;
 ; CC65 runtime: sub ints reversed
 ;
@@ -8,6 +9,8 @@
         .import         addysp1
         .importzp       sp, tmp1
 
+        .macpack        cpu
+
 ;
 ; AX = AX - TOS
 ;
 tosrsuba0:
         ldx     #0
 tosrsubax:
-        ldy     #0
         sec
+.if (.cpu .bitand CPU_ISET_65SC02)
+        sbc     (sp)
+        ldy     #1
+.else
+        ldy     #0
         sbc     (sp),y          ; lo byte
+        iny
+.endif
         sta     tmp1            ; save lo byte
         txa
-        iny
         sbc     (sp),y          ; hi byte
         tax
         lda     tmp1
index 90738e0d2d44c67b2c8c8ca0616c0b56cd298272..3114f449c8955e9e9e3dfc108e212249a850ad98 100644 (file)
@@ -1,5 +1,6 @@
 ;
 ; Ullrich von Bassewitz, 26.10.2000
+; Christian Krueger, 12-Mar-2017, added 65SC02 optimization
 ;
 ; CC65 runtime: Store a/x indirect into address at top of stack with index
 ;
@@ -8,6 +9,8 @@
         .import         incsp2
         .importzp       sp, tmp1, ptr1
 
+        .macpack        cpu
+
 .proc   staxspidx
 
         sty     tmp1            ; Save Y
         ldy     #1
         lda     (sp),y
         sta     ptr1+1
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+        lda     (sp)
+.else
         dey
         lda     (sp),y
+.endif
         sta     ptr1            ; Address now in ptr1
         ldy     tmp1            ; Restore Y
         iny                     ; Address high byte
index e91eeca31dd2aaf11a5a4928a901bd995f66d5a8..d4a74df5ff2f52b5bba790f309dc2bb0819a9dab 100644 (file)
@@ -1,5 +1,6 @@
 ;
 ; Ullrich von Bassewitz, 06.08.1998
+; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
 ;
 ; CC65 runtime: swap ax with TOS
 ;
@@ -7,6 +8,8 @@
         .export         swapstk
         .importzp       sp, ptr4
 
+        .macpack        cpu
+
 swapstk:
         sta     ptr4
         stx     ptr4+1
@@ -15,11 +18,18 @@ swapstk:
         tax
         lda     ptr4+1
         sta     (sp),y
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+        lda     (sp)
+        tay
+        lda     ptr4
+        sta     (sp)
+        tya    
+.else        
         dey
         lda     (sp),y
         pha
         lda     ptr4
         sta     (sp),y
         pla
+.endif        
         rts                     ; whew!
-
index 825c576d16d5356fba5599df881c3f9546b68aa9..e0392292694de9ea6c81aa3857920688c9cff164 100644 (file)
@@ -1,5 +1,6 @@
 ;
 ; Ullrich von Bassewitz, 05.08.1998
+; Christian Krueger, 11-Mar-2017, added 65SC02 optimization
 ;
 ; CC65 runtime: xor on ints
 ;
@@ -8,13 +9,20 @@
         .import         addysp1
         .importzp       sp, tmp1
 
+        .macpack        cpu
+
 tosxora0:
         ldx     #$00
 tosxorax:
+.if (.cpu .bitand CPU_ISET_65SC02)
+        eor     (sp)
+        ldy     #1
+.else
         ldy     #0
         eor     (sp),y
-        sta     tmp1
         iny
+.endif
+        sta     tmp1
         txa
         eor     (sp),y
         tax
index e0c8154e350ce97141328b3cea85c006dc5fccef..e1470f8485c41887cd4c6b8f596edd159f760c0f 100644 (file)
@@ -1,19 +1,26 @@
 ;
-; jede jede@oric.org 2017-02-25
+; 2017-02-25, jede <jede@oric.org>
+; 2017-06-15, Greg King
 ;
-    .export    _gotoxy
-       
-    .import    popa
-       
-    .importzp  sp
+; void gotoxy (unsigned char x, unsigned char y);
+;
+
+        .export         gotoxy, _gotoxy
+
+        .import         popa
+        .importzp       sp
 
-    .include   "telestrat.inc"
+        .include        "telestrat.inc"
+
+gotoxy: jsr     popa            ; Get Y
 
 .proc _gotoxy
-   ; This function move only cursor for display, it does not move the prompt position
-   ; in telemon, there is position for prompt, and another for the cursor
-   sta    SCRY
-   jsr    popa
-   sta    SCRX
-   rts
-.endproc       
+
+; This function moves only the display cursor; it does not move the prompt position.
+; In telemon, there is a position for the prompt, and another for the cursor.
+
+        sta     SCRY
+        jsr     popa
+        sta     SCRX
+        rts
+.endproc
index cdd4c274f8dfd64b4ae468b0e377186a3000effd..3b1db402afb885d06a9136daa52fea66caa8c05f 100644 (file)
 
         .addr   $0000
 
-; Button state masks (8 values)
-
-        .byte   $01                     ; JOY_UP
-        .byte   $02                     ; JOY_DOWN
-        .byte   $04                     ; JOY_LEFT
-        .byte   $08                     ; JOY_RIGHT
-        .byte   $10                     ; JOY_FIRE
-        .byte   $00                     ; JOY_FIRE2 unavailable
-        .byte   $00                     ; Future expansion
-        .byte   $00                     ; Future expansion
-
 ; Jump table.
 
         .addr   INSTALL
@@ -113,10 +102,21 @@ joy1:   lda     #$7F            ; mask for VIA2 JOYBIT: sw3
         sty     VIA1_DDRA       ; restore the state of DDRA
 
         cli                     ; necessary?
-        ror                     ; Shift sw3 into bit 7
-        and     #$9E            ; Mask relevant bits
-        eor     #$9E            ; Active states are inverted
+        php                     ; Save sw3 in carry
+        lsr                     ; Shift sw0,sw1,sw2,sw4 into bits 1-4
+        tax                     ; Save sw0,sw1,sw2
+        and     #$10            ; Extract sw4 in bit 4
+        sta     tmp1            ; Save sw4 in bit 4
+        txa                     ; Restore sw0,sw1,sw2
+        lsr                     ; Shift sw0,sw1,sw2 into bits 0-2
+        and     #$07            ; Mask bits 0-2
+        plp                     ; Restore sw3 in carry
+        bcc     @L0             ; Is sw3 set?
+        ora     #$08            ; Yes: Add sw3 in bit 3
+@L0:    ora     tmp1            ; Add sw4 in bit 4
+        eor     #$1F            ; Active states are inverted
 
+        ldx     #0
         rts
 
 ; Read joystick 2
@@ -131,8 +131,8 @@ joy2:   lda     #%10000000      ; via port B Data-Direction
         sta     VIA1_PRB        ; (output one at PB7)
 
         lda     VIA1_PRB        ; via port B read/write
-        and     #$1f            ; get bit 4-0 (PB4-PB0)
-        eor     #$1f
+        and     #$1F            ; get bit 4-0 (PB4-PB0)
+        eor     #$1F
         rts
 
 ; Read joystick 3
@@ -141,15 +141,14 @@ joy3:   lda     #$00            ; via port B read/write
         sta     VIA1_PRB        ; (output zero at PB7)
 
         lda     VIA1_PRB        ; via port B read/write
-        and     #$0f            ; get bit 3-0 (PB3-PB0)
+        and     #$0F            ; get bit 3-0 (PB3-PB0)
         sta     tmp1            ; joy 4 directions
 
         lda     VIA1_PRB        ; via port B read/write
         and     #%00100000      ; get bit 5 (PB5)
         lsr
         ora     tmp1
-        eor     #$1f
+        eor     #$1F
 
         ldx     #0
         rts
-
index 56fb35ae43d885cc6fb533b884b735f43734cbb0..67299cc1a8e34bd272968159b3170c747104fc79 100644 (file)
 
         .addr   $0000
 
-; Button state masks (8 values)
-
-        .byte   $02                     ; JOY_UP
-        .byte   $04                     ; JOY_DOWN
-        .byte   $08                     ; JOY_LEFT
-        .byte   $80                     ; JOY_RIGHT
-        .byte   $10                     ; JOY_FIRE
-        .byte   $00                     ; JOY_FIRE2 unavailable
-        .byte   $00                     ; Future expansion
-        .byte   $00                     ; Future expansion
-
 ; Jump table.
 
         .addr   INSTALL
@@ -112,10 +101,19 @@ READ:   lda     #$7F            ; mask for VIA2 JOYBIT: sw3
         sty     VIA1_DDRA       ; restore the state of DDRA
 
         cli                     ; necessary?
-        ror                     ; Shift sw3 into bit 7
-        and     #$9E            ; Mask relevant bits
-        eor     #$9E            ; Active states are inverted
-
+        php                     ; Save sw3 in carry
+        lsr                     ; Shift sw0,sw1,sw2,sw4 into bits 1-4
+        tax                     ; Save sw0,sw1,sw2
+        and     #$10            ; Extract sw4 in bit 4
+        sta     tmp1            ; Save sw4 in bit 4
+        txa                     ; Restore sw0,sw1,sw2
+        lsr                     ; Shift sw0,sw1,sw2 into bits 0-2
+        and     #$07            ; Mask bits 0-2
+        plp                     ; Restore sw3 in carry
+        bcc     @L0             ; Is sw3 set?
+        ora     #$08            ; Yes: Add sw3 in bit 3
+@L0:    ora     tmp1            ; Add sw4 in bit 4
+        eor     #$1F            ; Active states are inverted
+
+        ldx     #0
         rts
-
-
diff --git a/libsrc/vic20/kbrepeat.s b/libsrc/vic20/kbrepeat.s
new file mode 100644 (file)
index 0000000..dce4949
--- /dev/null
@@ -0,0 +1,14 @@
+;
+; unsigned char __fastcall__ kbrepeat (unsigned char mode);
+;
+
+        .export _kbrepeat
+
+        .include        "vic20.inc"
+
+_kbrepeat:
+        ldx KBDREPEAT           ; get old value
+        sta KBDREPEAT           ; store new value
+        txa                     ; return old value
+        ldx #0
+        rts
diff --git a/libsrc/vic20/waitvsync.s b/libsrc/vic20/waitvsync.s
new file mode 100644 (file)
index 0000000..1c76f24
--- /dev/null
@@ -0,0 +1,16 @@
+;
+; Written by Groepaz <groepaz@gmx.net>
+;
+; void waitvsync (void);
+;
+
+        .export         _waitvsync
+
+        .include        "vic20.inc"
+
+_waitvsync:
+@l2:
+        lda     VIC_HLINE
+        bne     @l2
+        rts
+
index edfeca689c42ff1b92823474d3266110f0e0bd8d..59841d6550d6ff1a52a66c33f305e1a19857a116 100644 (file)
@@ -90,7 +90,7 @@ LDFLAGS_tgidemo_atarixl    = --start-addr 0x4000
 %: %.s
 
 .c.o:
-       $(CC) $(CFLAGS) -Oirs --codesize 500 -T -g -t $(SYS) $<
+       $(CC) $(CFLAGS) -Ors --codesize 500 -T -g -t $(SYS) $<
        $(AS) $(<:.c=.s)
 
 .s.o:
@@ -237,10 +237,10 @@ samples.atr: samples
 # Installation rules
 
 INSTALL = install
-samplesdir = $(prefix)/share/cc65
+samplesdir = $(PREFIX)/share/cc65/samples
 
 install:
-       $(if $(prefix),,$(error variable `prefix' must be set))
+       $(if $(PREFIX),,$(error variable `PREFIX' must be set))
        $(INSTALL) -d $(DESTDIR)$(samplesdir)
        $(INSTALL) -d $(DESTDIR)$(samplesdir)/geos
        $(INSTALL) -d $(DESTDIR)$(samplesdir)/tutorial
index edb6f5aa8a25db449d57ee3350bbed451cd25603..8b41ceb9c55b58c0f87687f6371f63d082c291f4 100644 (file)
@@ -19,8 +19,8 @@ PROGS = ar65     \
 
 .SUFFIXES:
 
-bindir  := $(prefix)/bin
-datadir := $(if $(prefix),$(prefix)/share/cc65,$(abspath ..))
+bindir  := $(PREFIX)/bin
+datadir := $(if $(PREFIX),$(PREFIX)/share/cc65,$(abspath ..))
 
 CA65_INC = $(datadir)/asminc
 CC65_INC = $(datadir)/include
@@ -62,10 +62,10 @@ else
   endif
 endif
 
-CFLAGS += -MMD -MP -O -I common \
+CFLAGS += -MMD -MP -O3 -I common \
           -Wall -Wextra -Wno-char-subscripts $(USER_CFLAGS) \
           -DCA65_INC=$(CA65_INC) -DCC65_INC=$(CC65_INC) -DCL65_TGT=$(CL65_TGT) \
-          -DLD65_LIB=$(LD65_LIB) -DLD65_OBJ=$(LD65_OBJ) -DLD65_CFG=$(LD65_CFG)
+          -DLD65_LIB=$(LD65_LIB) -DLD65_OBJ=$(LD65_OBJ) -DLD65_CFG=$(LD65_CFG) \
           -DGIT_SHA=$(GIT_SHA)
 
 LDLIBS += -lm
@@ -107,7 +107,7 @@ $(RM) /usr/local/bin/$(prog)
 endef # UNAVAIL_recipe
 
 install:
-       $(if $(prefix),,$(error variable `prefix' must be set))
+       $(if $(PREFIX),,$(error variable `PREFIX' must be set))
        $(INSTALL) -d $(DESTDIR)$(bindir)
        $(INSTALL) ../bin/* $(DESTDIR)$(bindir)
 
index 6562998605e616b91c7e832357334613ddc1416e..367c950dc0d8e00e7aeba3e34086965294d14f4d 100644 (file)
@@ -36,6 +36,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+/* common */
+#include "print.h"
+
 /* ar65 */
 #include "error.h"
 #include "library.h"
@@ -73,8 +76,10 @@ void ListObjFiles (int argc, char* argv [])
         /* Get the entry */
         O = CollConstAt (&ObjPool, I);
 
+        /* Print the size if verbose */
+        Print (stdout, 1, "%5lu ", O->Size);
         /* Print the name */
-        printf ("%s\n", O->Name);
+        puts (O->Name);
 
     }
 
index a1839bad290b214f161f80912d1462758c2af2b6..48561027fb109972479810378b301f8977acc35c 100644 (file)
@@ -62,9 +62,9 @@ static void Usage (void)
 {
     fprintf (stderr, "Usage: %s <operation ...> lib file|module ...\n"
             "Operations are some of:\n"
-            "\ta\tAdd modules\n"
+            "\tr\tAdd modules\n"
             "\td\tDelete modules\n"
-            "\tl\tList library contents\n"
+            "\tt\tList library table\n"
             "\tv\tIncrease verbosity (put before other operation)\n"
             "\tx\tExtract modules\n"
             "\tV\tPrint the archiver version\n",
@@ -94,13 +94,10 @@ int main (int argc, char* argv [])
         /* Get the argument */
         const char* Arg = ArgVec [I];
 
-        /* Check for an option */
-        if (strlen (Arg) != 1) {
-            Usage ();
-        }
         switch (Arg [0]) {
 
-            case 'a':
+            case 'r': /* POSIX.2 */
+            case 'a': /* staying compatible */
                 AddObjFiles (ArgCount - I - 1, &ArgVec[I+1]);
                 break;
 
@@ -108,7 +105,11 @@ int main (int argc, char* argv [])
                 DelObjFiles (ArgCount - I - 1, &ArgVec [I+1]);
                 break;
 
-            case 'l':
+            case 't': /* POSIX.2 */
+            case 'l': /* staying compatible */
+                if (Arg [1] == 'v') {
+                    ++Verbosity;
+                }
                 ListObjFiles (ArgCount - I - 1, &ArgVec [I+1]);
                 break;
 
index 8a55f9ddc6e836b538b033002d36c2c1642bc07b..135739fb5213abc80ceffa343ea51827ba695d3d 100644 (file)
@@ -211,7 +211,7 @@ void DbgInfoFile (void)
 void DbgInfoFunc (void)
 /* Parse and handle func subcommand of the .dbg pseudo instruction */
 {
-    static const char* StorageKeys[] = {
+    static const char* const StorageKeys[] = {
         "EXTERN",
         "STATIC",
     };
@@ -352,7 +352,7 @@ void DbgInfoLine (void)
 void DbgInfoSym (void)
 /* Parse and handle SYM subcommand of the .dbg pseudo instruction */
 {
-    static const char* StorageKeys[] = {
+    static const char* const StorageKeys[] = {
         "AUTO",
         "EXTERN",
         "REGISTER",
index 35bdf4b98412438d3d048f7107325ef0b9f10bc4..0fb766b6f6c87dbf19c9bcca2884a27c1d7a408b 100644 (file)
@@ -48,7 +48,7 @@
 
 
 /* Names of the features */
-static const char* FeatureKeys[FEAT_COUNT] = {
+static const char* const FeatureKeys[FEAT_COUNT] = {
     "dollar_is_pc",
     "labels_without_colons",
     "loose_string_term",
index 3c3daf7f72287f3aa1c5ccdb6ffa87cfccd7992b..fbca2beacf7dd9f47f9b2009659c3b6960bb87fc 100644 (file)
@@ -123,7 +123,6 @@ static void Usage (void)
             "  --large-alignment\t\tDon't warn about large alignments\n"
             "  --listing name\t\tCreate a listing file if assembly was ok\n"
             "  --list-bytes n\t\tMaximum number of bytes per listing line\n"
-            "  --macpack-dir dir\t\tSet a macro package directory\n"
             "  --memory-model model\t\tSet the memory model\n"
             "  --pagelength n\t\tSet the page length for the listing\n"
             "  --relax-checks\t\tRelax some checks (see docs)\n"
index b44c28dd87d5cf9adbb501a7f4b2e05673629e57..5dd67af9066918bb877a4b4a5b7622442c25389f 100644 (file)
@@ -151,7 +151,7 @@ static unsigned char OptionalAddrSize (void)
 static void SetBoolOption (unsigned char* Flag)
 /* Read a on/off/+/- option and set flag accordingly */
 {
-    static const char* Keys[] = {
+    static const char* const Keys[] = {
         "OFF",
         "ON",
     };
@@ -451,7 +451,7 @@ static void DoASCIIZ (void)
 static void DoAssert (void)
 /* Add an assertion */
 {
-    static const char* ActionTab [] = {
+    static const char* const ActionTab [] = {
         "WARN", "WARNING",
         "ERROR",
         "LDWARN", "LDWARNING",
@@ -659,7 +659,7 @@ static void DoCode (void)
 static void DoConDes (void)
 /* Export a symbol as constructor/destructor */
 {
-    static const char* Keys[] = {
+    static const char* const Keys[] = {
         "CONSTRUCTOR",
         "DESTRUCTOR",
         "INTERRUPTOR",
@@ -744,7 +744,7 @@ static void DoData (void)
 static void DoDbg (void)
 /* Add debug information from high level code */
 {
-    static const char* Keys[] = {
+    static const char* const Keys[] = {
         "FILE",
         "FUNC",
         "LINE",
@@ -1039,7 +1039,7 @@ static void DoFileOpt (void)
     if (CurTok.Tok == TOK_IDENT) {
 
         /* Option given as keyword */
-        static const char* Keys [] = {
+        static const char* const Keys [] = {
             "AUTHOR", "COMMENT", "COMPILER"
         };
 
@@ -1388,7 +1388,7 @@ static void DoList (void)
 /* Enable/disable the listing */
 {
     /* Get the setting */
-    unsigned char List;
+    unsigned char List = 0;
     SetBoolOption (&List);
 
     /* Manage the counter */
index e186b19a79149f9f03f37c1e0ff7e94fd5e5cb4b..7c291666c47ede9a8cc202f58636cae5d75e5dfc 100644 (file)
@@ -1477,7 +1477,7 @@ CharAgain:
 
 
 
-int GetSubKey (const char** Keys, unsigned Count)
+int GetSubKey (const char* const* Keys, unsigned Count)
 /* Search for a subkey in a table of keywords. The current token must be an
 ** identifier and all keys must be in upper case. The identifier will be
 ** uppercased in the process. The function returns the index of the keyword,
index c445aefa6f5ffb59e371d28d495de762ff688ed2..4fd9041c105974630f1c4edb1a508489caed2b2a 100644 (file)
@@ -84,7 +84,7 @@ void UpcaseSVal (void);
 void NextRawTok (void);
 /* Read the next raw token from the input stream */
 
-int GetSubKey (const char** Keys, unsigned Count);
+int GetSubKey (const char* const* Keys, unsigned Count);
 /* Search for a subkey in a table of keywords. The current token must be an
 ** identifier and all keys must be in upper case. The identifier will be
 ** uppercased in the process. The function returns the index of the keyword,
index 1c1f993fe0960ae795d357acc3dba96d993513bf..70f43dc73212f85ed515906e9118c626393753ba 100644 (file)
     <ClInclude Include="cc65\typecmp.h" />
     <ClInclude Include="cc65\typeconv.h" />
     <ClInclude Include="cc65\util.h" />
+    <ClInclude Include="cc65\wrappedcall.h" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="cc65\anonname.c" />
     <ClCompile Include="cc65\typecmp.c" />
     <ClCompile Include="cc65\typeconv.c" />
     <ClCompile Include="cc65\util.c" />
+    <ClCompile Include="cc65\wrappedcall.c" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
index bf0251813619859df15c110108c12e8c404a87ba..dfc06fccc08a52757c5f5268391024abb6347b26 100644 (file)
@@ -2211,7 +2211,7 @@ void g_cmp (unsigned flags, unsigned long val)
 
 
 
-static void oper (unsigned Flags, unsigned long Val, const char** Subs)
+static void oper (unsigned Flags, unsigned long Val, const char* const* Subs)
 /* Encode a binary operation. subs is a pointer to four strings:
 **      0       --> Operate on ints
 **      1       --> Operate on unsigneds
@@ -2499,7 +2499,7 @@ void g_stackcheck (void)
 void g_add (unsigned flags, unsigned long val)
 /* Primary = TOS + Primary */
 {
-    static const char* ops[12] = {
+    static const char* const ops[4] = {
         "tosaddax", "tosaddax", "tosaddeax", "tosaddeax"
     };
 
@@ -2515,8 +2515,8 @@ void g_add (unsigned flags, unsigned long val)
 void g_sub (unsigned flags, unsigned long val)
 /* Primary = TOS - Primary */
 {
-    static const char* ops[12] = {
-        "tossubax", "tossubax", "tossubeax", "tossubeax",
+    static const char* const ops[4] = {
+        "tossubax", "tossubax", "tossubeax", "tossubeax"
     };
 
     if (flags & CF_CONST) {
@@ -2531,8 +2531,8 @@ void g_sub (unsigned flags, unsigned long val)
 void g_rsub (unsigned flags, unsigned long val)
 /* Primary = Primary - TOS */
 {
-    static const char* ops[12] = {
-        "tosrsubax", "tosrsubax", "tosrsubeax", "tosrsubeax",
+    static const char* const ops[4] = {
+        "tosrsubax", "tosrsubax", "tosrsubeax", "tosrsubeax"
     };
     oper (flags, val, ops);
 }
@@ -2542,8 +2542,8 @@ void g_rsub (unsigned flags, unsigned long val)
 void g_mul (unsigned flags, unsigned long val)
 /* Primary = TOS * Primary */
 {
-    static const char* ops[12] = {
-        "tosmulax", "tosumulax", "tosmuleax", "tosumuleax",
+    static const char* const ops[4] = {
+        "tosmulax", "tosumulax", "tosmuleax", "tosumuleax"
     };
 
     int p2;
@@ -2649,8 +2649,8 @@ void g_mul (unsigned flags, unsigned long val)
 void g_div (unsigned flags, unsigned long val)
 /* Primary = TOS / Primary */
 {
-    static const char* ops[12] = {
-        "tosdivax", "tosudivax", "tosdiveax", "tosudiveax",
+    static const char* const ops[4] = {
+        "tosdivax", "tosudivax", "tosdiveax", "tosudiveax"
     };
 
     /* Do strength reduction if the value is constant and a power of two */
@@ -2674,8 +2674,8 @@ void g_div (unsigned flags, unsigned long val)
 void g_mod (unsigned flags, unsigned long val)
 /* Primary = TOS % Primary */
 {
-    static const char* ops[12] = {
-        "tosmodax", "tosumodax", "tosmodeax", "tosumodeax",
+    static const char* const ops[4] = {
+        "tosmodax", "tosumodax", "tosmodeax", "tosumodeax"
     };
     int p2;
 
@@ -2699,8 +2699,8 @@ void g_mod (unsigned flags, unsigned long val)
 void g_or (unsigned flags, unsigned long val)
 /* Primary = TOS | Primary */
 {
-    static const char* ops[12] = {
-        "tosorax", "tosorax", "tosoreax", "tosoreax",
+    static const char* const ops[4] = {
+        "tosorax", "tosorax", "tosoreax", "tosoreax"
     };
 
     /* If the right hand side is const, the lhs is not on stack but still
@@ -2769,8 +2769,8 @@ void g_or (unsigned flags, unsigned long val)
 void g_xor (unsigned flags, unsigned long val)
 /* Primary = TOS ^ Primary */
 {
-    static const char* ops[12] = {
-        "tosxorax", "tosxorax", "tosxoreax", "tosxoreax",
+    static const char* const ops[4] = {
+        "tosxorax", "tosxorax", "tosxoreax", "tosxoreax"
     };
 
 
@@ -2837,8 +2837,8 @@ void g_xor (unsigned flags, unsigned long val)
 void g_and (unsigned Flags, unsigned long Val)
 /* Primary = TOS & Primary */
 {
-    static const char* ops[12] = {
-        "tosandax", "tosandax", "tosandeax", "tosandeax",
+    static const char* const ops[4] = {
+        "tosandax", "tosandax", "tosandeax", "tosandeax"
     };
 
     /* If the right hand side is const, the lhs is not on stack but still
@@ -2929,8 +2929,8 @@ void g_and (unsigned Flags, unsigned long Val)
 void g_asr (unsigned flags, unsigned long val)
 /* Primary = TOS >> Primary */
 {
-    static const char* ops[12] = {
-        "tosasrax", "tosshrax", "tosasreax", "tosshreax",
+    static const char* const ops[4] = {
+        "tosasrax", "tosshrax", "tosasreax", "tosshreax"
     };
 
     /* If the right hand side is const, the lhs is not on stack but still
@@ -3060,8 +3060,8 @@ void g_asr (unsigned flags, unsigned long val)
 void g_asl (unsigned flags, unsigned long val)
 /* Primary = TOS << Primary */
 {
-    static const char* ops[12] = {
-        "tosaslax", "tosshlax", "tosasleax", "tosshleax",
+    static const char* const ops[4] = {
+        "tosaslax", "tosshlax", "tosasleax", "tosshleax"
     };
 
 
@@ -3438,8 +3438,8 @@ void g_dec (unsigned flags, unsigned long val)
 void g_eq (unsigned flags, unsigned long val)
 /* Test for equal */
 {
-    static const char* ops[12] = {
-        "toseqax", "toseqax", "toseqeax", "toseqeax",
+    static const char* const ops[4] = {
+        "toseqax", "toseqax", "toseqeax", "toseqeax"
     };
 
     unsigned L;
@@ -3492,8 +3492,8 @@ void g_eq (unsigned flags, unsigned long val)
 void g_ne (unsigned flags, unsigned long val)
 /* Test for not equal */
 {
-    static const char* ops[12] = {
-        "tosneax", "tosneax", "tosneeax", "tosneeax",
+    static const char* const ops[4] = {
+        "tosneax", "tosneax", "tosneeax", "tosneeax"
     };
 
     unsigned L;
@@ -3546,8 +3546,8 @@ void g_ne (unsigned flags, unsigned long val)
 void g_lt (unsigned flags, unsigned long val)
 /* Test for less than */
 {
-    static const char* ops[12] = {
-        "tosltax", "tosultax", "toslteax", "tosulteax",
+    static const char* const ops[4] = {
+        "tosltax", "tosultax", "toslteax", "tosulteax"
     };
 
     unsigned Label;
@@ -3708,8 +3708,8 @@ void g_lt (unsigned flags, unsigned long val)
 void g_le (unsigned flags, unsigned long val)
 /* Test for less than or equal to */
 {
-    static const char* ops[12] = {
-        "tosleax", "tosuleax", "tosleeax", "tosuleeax",
+    static const char* const ops[4] = {
+        "tosleax", "tosuleax", "tosleeax", "tosuleeax"
     };
 
 
@@ -3823,8 +3823,8 @@ void g_le (unsigned flags, unsigned long val)
 void g_gt (unsigned flags, unsigned long val)
 /* Test for greater than */
 {
-    static const char* ops[12] = {
-        "tosgtax", "tosugtax", "tosgteax", "tosugteax",
+    static const char* const ops[4] = {
+        "tosgtax", "tosugtax", "tosgteax", "tosugteax"
     };
 
 
@@ -3954,8 +3954,8 @@ void g_gt (unsigned flags, unsigned long val)
 void g_ge (unsigned flags, unsigned long val)
 /* Test for greater than or equal to */
 {
-    static const char* ops[12] = {
-        "tosgeax", "tosugeax", "tosgeeax", "tosugeeax",
+    static const char* const ops[4] = {
+        "tosgeax", "tosugeax", "tosgeeax", "tosugeeax"
     };
 
     unsigned Label;
index de51781a61c1af42fef0e06b4ec132e86c9aa7d4..e9d98f5b870d9b5021b0925b022f5915878bff49 100644 (file)
@@ -401,6 +401,11 @@ void GetFuncInfo (const char* Name, unsigned short* Use, unsigned short* Chg)
             */
             if ((D->Flags & FD_VARIADIC) != 0) {
                 *Use = REG_Y;
+            } else if (D->Flags & FD_CALL_WRAPPER) {
+                /* Wrappers may go to any functions, so mark them as using all
+                ** registers.
+                */
+                *Use = REG_EAXY;
             } else if (D->ParamCount > 0 &&
                        (AutoCDecl ?
                         IsQualFastcall (E->Type) :
index 9f1ab29f55a0a89d1945f8e649f11ccd357364cb..d79ef350b9ff102d86afc8b45f787bf0d5c5065b 100644 (file)
@@ -157,7 +157,7 @@ static void Parse (void)
                   CurTok.Tok == TOK_ASSIGN))) {
 
                 /* We will allocate storage */
-                Decl.StorageClass |= SC_STORAGE | SC_DEF;
+                Decl.StorageClass |= SC_STORAGE;
             }
 
             /* If this is a function declarator that is not followed by a comma
@@ -190,6 +190,13 @@ static void Parse (void)
                 /* Allow initialization */
                 if (CurTok.Tok == TOK_ASSIGN) {
 
+                    /* This is a definition */
+                    if (SymIsDef (Entry)) {
+                        Error ("Global variable `%s' has already been defined",
+                               Entry->Name);
+                    }
+                    Entry->Flags |= SC_DEF;
+
                     /* We cannot initialize types of unknown size, or
                     ** void types in ISO modes.
                     */
@@ -235,19 +242,24 @@ static void Parse (void)
                             Error ("Variable `%s' has unknown size", Decl.Ident);
                         }
                         Entry->Flags &= ~(SC_STORAGE | SC_DEF);
-                    }
-
-                    /* Allocate storage if it is still needed */
-                    if (Entry->Flags & SC_STORAGE) {
-
-                        /* Switch to the BSS segment */
-                        g_usebss ();
-
-                        /* Define a label */
-                        g_defgloblabel (Entry->Name);
-
-                        /* Allocate space for uninitialized variable */
-                        g_res (Size);
+                    } else {
+                        /* A global (including static) uninitialized variable is
+                        ** only a tentative definition. For example, this is valid:
+                        ** int i;
+                        ** int i;
+                        ** static int j;
+                        ** static int j = 42;
+                        ** Code for them will be generated by FinishCompile().
+                        ** For now, just save the BSS segment name
+                        ** (can be set by #pragma bss-name).
+                        */
+                        const char* bssName = GetSegName (SEG_BSS);
+
+                        if (Entry->V.BssName && strcmp (Entry->V.BssName, bssName) != 0) {
+                            Error ("Global variable `%s' already was defined in the `%s' segment.",
+                                   Entry->Name, Entry->V.BssName);
+                        }
+                        Entry->V.BssName = xstrdup (bssName);
                     }
                 }
 
@@ -303,7 +315,7 @@ void Compile (const char* FileName)
     struct tm*  TM;
 
     /* Since strftime is locale dependent, we need the abbreviated month names
-    ** in english.
+    ** in English.
     */
     static const char MonthNames[12][4] = {
         "Jan", "Feb", "Mar", "Apr", "May", "Jun",
@@ -324,17 +336,22 @@ void Compile (const char* FileName)
     ** changes using #pragma later.
     */
     if (IS_Get (&Optimize)) {
-        long CodeSize = IS_Get (&CodeSizeFactor);
         DefineNumericMacro ("__OPT__", 1);
+    }
+    {
+        long CodeSize = IS_Get (&CodeSizeFactor);
         if (CodeSize > 100) {
             DefineNumericMacro ("__OPT_i__", CodeSize);
         }
-        if (IS_Get (&EnableRegVars)) {
-            DefineNumericMacro ("__OPT_r__", 1);
-        }
-        if (IS_Get (&InlineStdFuncs)) {
-            DefineNumericMacro ("__OPT_s__", 1);
-        }
+    }
+    if (IS_Get (&EnableRegVars)) {
+        DefineNumericMacro ("__OPT_r__", 1);
+    }
+    if (IS_Get (&InlineStdFuncs)) {
+        DefineNumericMacro ("__OPT_s__", 1);
+    }
+    if (IS_Get (&EagerlyInlineFuncs)) {
+        DefineNumericMacro ("__EAGERLY_INLINE_FUNCS__", 1);
     }
 
     /* __TIME__ and __DATE__ macros */
@@ -400,20 +417,32 @@ void Compile (const char* FileName)
 void FinishCompile (void)
 /* Emit literals, externals, debug info, do cleanup and optimizations */
 {
-    SymTable* SymTab;
-    SymEntry* Func;
-
-    /* Walk over all functions, doing cleanup, optimizations ... */
-    SymTab = GetGlobalSymTab ();
-    Func   = SymTab->SymHead;
-    while (Func) {
-        if (SymIsOutputFunc (Func)) {
+    SymEntry* Entry;
+
+    /* Walk over all global symbols:
+    ** - for functions, do clean-up and optimizations
+    ** - generate code for uninitialized global variables
+    */
+    for (Entry = GetGlobalSymTab ()->SymHead; Entry; Entry = Entry->NextSym) {
+        if (SymIsOutputFunc (Entry)) {
             /* Function which is defined and referenced or extern */
-            MoveLiteralPool (Func->V.F.LitPool);
-            CS_MergeLabels (Func->V.F.Seg->Code);
-            RunOpt (Func->V.F.Seg->Code);
+            MoveLiteralPool (Entry->V.F.LitPool);
+            CS_MergeLabels (Entry->V.F.Seg->Code);
+            RunOpt (Entry->V.F.Seg->Code);
+        } else if ((Entry->Flags & (SC_STORAGE | SC_DEF | SC_STATIC)) == (SC_STORAGE | SC_STATIC)) {
+            /* Assembly definition of uninitialized global variable */
+
+            /* Set the segment name only when it changes */
+            if (strcmp (GetSegName (SEG_BSS), Entry->V.BssName) != 0) {
+                SetSegName (SEG_BSS, Entry->V.BssName);
+                g_segname (SEG_BSS);
+            }
+            g_usebss ();
+            g_defgloblabel (Entry->Name);
+            g_res (SizeOf (Entry->Type));
+            /* Mark as defined; so that it will be exported, not imported */
+            Entry->Flags |= SC_DEF;
         }
-        Func = Func->NextSym;
     }
 
     /* Output the literal pool */
index cf6392bd33a930a426f7d22b77c6e0d8fbc998dd..41d928750f5ef896f92086576dbe3f83416f5cfd 100644 (file)
@@ -1711,7 +1711,7 @@ static int HarmlessCall (const char* Name)
 ** the pushax/op sequence when encountered.
 */
 {
-    static const char* Tab[] = {
+    static const char* const Tab[] = {
         "aslax1",
         "aslax2",
         "aslax3",
index 8c9d6dcb00d6feb81cf12b7b2cc28316d7023c8f..2d54316cd9cbba88b28f97773107e48c8e132cac 100644 (file)
@@ -389,7 +389,10 @@ unsigned SizeOf (const Type* T)
     switch (UnqualifiedType (T->C)) {
 
         case T_VOID:
-            return 0;   /* Assume voids have size zero */
+            /* A void variable is a cc65 extension.
+            ** Get its size (in bytes).
+            */
+            return T->A.U;
 
         /* Beware: There's a chance that this triggers problems in other parts
            of the compiler. The solution is to fix the callers, because calling
@@ -438,7 +441,7 @@ unsigned SizeOf (const Type* T)
                 /* Array with unspecified size */
                 return 0;
             } else {
-                return T->A.L * SizeOf (T + 1);
+                return T->A.U * SizeOf (T + 1);
             }
 
         default:
index 1630848350892bafc71df8006490d3720c8e35c9..a6b2329051b3d339412a77640bd501f1a63b7bc7 100644 (file)
@@ -58,6 +58,7 @@
 #include "scanner.h"
 #include "standard.h"
 #include "symtab.h"
+#include "wrappedcall.h"
 #include "typeconv.h"
 
 
@@ -891,6 +892,7 @@ static void ParseTypeSpec (DeclSpec* D, long Default, TypeCode Qualifiers)
         case TOK_VOID:
             NextToken ();
             D->Type[0].C = T_VOID;
+            D->Type[0].A.U = 0;
             D->Type[1].C = T_END;
             break;
 
@@ -1314,6 +1316,8 @@ static FuncDesc* ParseFuncDecl (void)
 {
     unsigned Offs;
     SymEntry* Sym;
+    SymEntry* WrappedCall;
+    unsigned char WrappedCallData;
 
     /* Create a new function descriptor */
     FuncDesc* F = NewFuncDesc ();
@@ -1379,6 +1383,13 @@ static FuncDesc* ParseFuncDecl (void)
     /* Leave the lexical level remembering the symbol tables */
     RememberFunctionLevel (F);
 
+    /* Did we have a WrappedCall for this function? */
+    GetWrappedCall((void **) &WrappedCall, &WrappedCallData);
+    if (WrappedCall) {
+        F->WrappedCall = WrappedCall;
+        F->WrappedCallData = WrappedCallData;
+    }
+
     /* Return the function descriptor */
     return F;
 }
@@ -1446,6 +1457,7 @@ static void Declarator (const DeclSpec* Spec, Declaration* D, declmode_t Mode)
 
             /* Function declaration */
             FuncDesc* F;
+            SymEntry* PrevEntry;
 
             /* Skip the opening paren */
             NextToken ();
@@ -1459,6 +1471,16 @@ static void Declarator (const DeclSpec* Spec, Declaration* D, declmode_t Mode)
                 Qualifiers &= ~T_QUAL_FASTCALL;
             }
 
+            /* Was there a previous entry? If so, copy WrappedCall info from it */
+            PrevEntry = FindGlobalSym (D->Ident);
+            if (PrevEntry && PrevEntry->Flags & SC_FUNC) {
+                FuncDesc* D = PrevEntry->V.F.Func;
+                if (D->WrappedCall && !F->WrappedCall) {
+                    F->WrappedCall = D->WrappedCall;
+                    F->WrappedCallData = D->WrappedCallData;
+                }
+            }
+
             /* Add the function type. Be sure to bounds check the type buffer */
             NeedTypeSpace (D, 1);
             D->Type[D->Index].C = T_FUNC | Qualifiers;
@@ -2114,7 +2136,7 @@ NextMember:
 
 
 
-static unsigned ParseVoidInit (void)
+static unsigned ParseVoidInit (Type* T)
 /* Parse an initialization of a void variable (special cc65 extension).
 ** Return the number of bytes initialized.
 */
@@ -2181,6 +2203,9 @@ static unsigned ParseVoidInit (void)
     /* Closing brace */
     ConsumeRCurly ();
 
+    /* Number of bytes determined by initializer */
+    T->A.U = Size;
+
     /* Return the number of bytes initialized */
     return Size;
 }
@@ -2216,8 +2241,8 @@ static unsigned ParseInitInternal (Type* T, int AllowFlexibleMembers)
 
         case T_VOID:
             if (IS_Get (&Standard) == STD_CC65) {
-                /* Special cc65 extension in non ANSI mode */
-                return ParseVoidInit ();
+                /* Special cc65 extension in non-ANSI mode */
+                return ParseVoidInit (T);
             }
             /* FALLTHROUGH */
 
index 34cf550a2e780b7e59b330297024930cd9d004e0..acfd95fed1d37fcc9de682b4d3820e9bd393a1cf 100644 (file)
@@ -536,6 +536,10 @@ static void FunctionCall (ExprDesc* Expr)
     /* Special handling for function pointers */
     if (IsFuncPtr) {
 
+        if (Func->WrappedCall) {
+            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
         ** the function into the primary.
         */
@@ -584,7 +588,47 @@ static void FunctionCall (ExprDesc* Expr)
     } else {
 
         /* Normal function */
-        g_call (TypeOf (Expr->Type), (const char*) Expr->Name, ParamSize);
+        if (Func->WrappedCall) {
+            char tmp[64];
+            StrBuf S = AUTO_STRBUF_INITIALIZER;
+
+            /* Store the WrappedCall data in tmp4 */
+            sprintf(tmp, "ldy #%u", Func->WrappedCallData);
+            SB_AppendStr (&S, tmp);
+            g_asmcode (&S);
+            SB_Clear(&S);
+
+            SB_AppendStr (&S, "sty tmp4");
+            g_asmcode (&S);
+            SB_Clear(&S);
+
+            /* Store the original function address in ptr4 */
+            SB_AppendStr (&S, "ldy #<(_");
+            SB_AppendStr (&S, (const char*) Expr->Name);
+            SB_AppendChar (&S, ')');
+            g_asmcode (&S);
+            SB_Clear(&S);
+
+            SB_AppendStr (&S, "sty ptr4");
+            g_asmcode (&S);
+            SB_Clear(&S);
+
+            SB_AppendStr (&S, "ldy #>(_");
+            SB_AppendStr (&S, (const char*) Expr->Name);
+            SB_AppendChar (&S, ')');
+            g_asmcode (&S);
+            SB_Clear(&S);
+
+            SB_AppendStr (&S, "sty ptr4+1");
+            g_asmcode (&S);
+            SB_Clear(&S);
+
+            SB_Done (&S);
+
+            g_call (TypeOf (Expr->Type), Func->WrappedCall->Name, ParamSize);
+        } else {
+            g_call (TypeOf (Expr->Type), (const char*) Expr->Name, ParamSize);
+        }
 
     }
 
@@ -1534,25 +1578,34 @@ static void PostInc (ExprDesc* Expr)
     /* Get the data type */
     Flags = TypeOf (Expr->Type);
 
-    /* Push the address if needed */
-    PushAddr (Expr);
+    /* Emit smaller code if a char variable is at a constant location */
+    if ((Flags & CF_CHAR) == CF_CHAR && ED_IsLocConst(Expr)) {
 
-    /* Fetch the value and save it (since it's the result of the expression) */
-    LoadExpr (CF_NONE, Expr);
-    g_save (Flags | CF_FORCECHAR);
+        LoadExpr (CF_NONE, Expr);
+        AddCodeLine ("inc %s", ED_GetLabelName(Expr, 0));
 
-    /* If we have a pointer expression, increment by the size of the type */
-    if (IsTypePtr (Expr->Type)) {
-        g_inc (Flags | CF_CONST | CF_FORCECHAR, CheckedSizeOf (Expr->Type + 1));
     } else {
-        g_inc (Flags | CF_CONST | CF_FORCECHAR, 1);
-    }
 
-    /* Store the result back */
-    Store (Expr, 0);
+        /* Push the address if needed */
+        PushAddr (Expr);
+
+        /* Fetch the value and save it (since it's the result of the expression) */
+        LoadExpr (CF_NONE, Expr);
+        g_save (Flags | CF_FORCECHAR);
+
+        /* If we have a pointer expression, increment by the size of the type */
+        if (IsTypePtr (Expr->Type)) {
+            g_inc (Flags | CF_CONST | CF_FORCECHAR, CheckedSizeOf (Expr->Type + 1));
+        } else {
+            g_inc (Flags | CF_CONST | CF_FORCECHAR, 1);
+        }
 
-    /* Restore the original value in the primary register */
-    g_restore (Flags | CF_FORCECHAR);
+        /* Store the result back */
+        Store (Expr, 0);
+
+        /* Restore the original value in the primary register */
+        g_restore (Flags | CF_FORCECHAR);
+    }
 
     /* The result is always an expression, no reference */
     ED_MakeRValExpr (Expr);
@@ -1581,25 +1634,34 @@ static void PostDec (ExprDesc* Expr)
     /* Get the data type */
     Flags = TypeOf (Expr->Type);
 
-    /* Push the address if needed */
-    PushAddr (Expr);
+    /* Emit smaller code if a char variable is at a constant location */
+    if ((Flags & CF_CHAR) == CF_CHAR && ED_IsLocConst(Expr)) {
 
-    /* Fetch the value and save it (since it's the result of the expression) */
-    LoadExpr (CF_NONE, Expr);
-    g_save (Flags | CF_FORCECHAR);
+        LoadExpr (CF_NONE, Expr);
+        AddCodeLine ("dec %s", ED_GetLabelName(Expr, 0));
 
-    /* If we have a pointer expression, increment by the size of the type */
-    if (IsTypePtr (Expr->Type)) {
-        g_dec (Flags | CF_CONST | CF_FORCECHAR, CheckedSizeOf (Expr->Type + 1));
     } else {
-        g_dec (Flags | CF_CONST | CF_FORCECHAR, 1);
-    }
 
-    /* Store the result back */
-    Store (Expr, 0);
+        /* Push the address if needed */
+        PushAddr (Expr);
 
-    /* Restore the original value in the primary register */
-    g_restore (Flags | CF_FORCECHAR);
+        /* Fetch the value and save it (since it's the result of the expression) */
+        LoadExpr (CF_NONE, Expr);
+        g_save (Flags | CF_FORCECHAR);
+
+        /* If we have a pointer expression, increment by the size of the type */
+        if (IsTypePtr (Expr->Type)) {
+            g_dec (Flags | CF_CONST | CF_FORCECHAR, CheckedSizeOf (Expr->Type + 1));
+        } else {
+            g_dec (Flags | CF_CONST | CF_FORCECHAR, 1);
+        }
+
+        /* Store the result back */
+        Store (Expr, 0);
+
+        /* Restore the original value in the primary register */
+        g_restore (Flags | CF_FORCECHAR);
+    }
 
     /* The result is always an expression, no reference */
     ED_MakeRValExpr (Expr);
index b9561a97cc4d6a68040a33d2ceadb0f61125f1a7..273263decc34383316fafb46f48f9c3f11b51f7d 100644 (file)
@@ -60,6 +60,8 @@ FuncDesc* NewFuncDesc (void)
     F->ParamCount = 0;
     F->ParamSize  = 0;
     F->LastParam  = 0;
+    F->WrappedCall = 0;
+    F->WrappedCallData = 0;
 
     /* Return the new struct */
     return F;
index b79c6a055ceb0384c71258c67d1658bc8e667800..a04ffb14a4bf037395bfe7e22083646318e7599f 100644 (file)
 #define FD_OLDSTYLE             0x0010U /* Old style (K&R) function          */
 #define FD_OLDSTYLE_INTRET      0x0020U /* K&R func has implicit int return  */
 #define FD_UNNAMED_PARAMS       0x0040U /* Function has unnamed params       */
+#define FD_CALL_WRAPPER         0x0080U /* This function is used as a wrapper */
 
 /* Bits that must be ignored when comparing funcs */
-#define FD_IGNORE       (FD_OLDSTYLE | FD_OLDSTYLE_INTRET | FD_UNNAMED_PARAMS)
+#define FD_IGNORE       (FD_OLDSTYLE | FD_OLDSTYLE_INTRET | FD_UNNAMED_PARAMS | FD_CALL_WRAPPER)
 
 
 
@@ -67,6 +68,8 @@ struct FuncDesc {
     unsigned            ParamCount;     /* Number of parameters              */
     unsigned            ParamSize;      /* Size of the parameters            */
     struct SymEntry*    LastParam;      /* Pointer to last parameter         */
+    struct SymEntry*    WrappedCall;    /* Pointer to the WrappedCall        */
+    unsigned char       WrappedCallData;/* The WrappedCall's user data       */
 };
 
 
index dbdd72f3c9bcd6d4ac26df9970eeb494efb6592b..a337549fea051a737ef0c939113cef7aec625964 100644 (file)
@@ -53,7 +53,8 @@ unsigned      RegisterSpace     = 6;    /* Space available for register vars */
 /* Stackable options */
 IntStack WritableStrings    = INTSTACK(0);  /* Literal strings are r/w */
 IntStack LocalStrings       = INTSTACK(0);  /* Emit string literals immediately */
-IntStack InlineStdFuncs     = INTSTACK(0);  /* Inline some known functions */
+IntStack InlineStdFuncs     = INTSTACK(0);  /* Inline some standard functions */
+IntStack EagerlyInlineFuncs = INTSTACK(0);  /* Eagerly inline some known functions */
 IntStack EnableRegVars      = INTSTACK(0);  /* Enable register variables */
 IntStack AllowRegVarAddr    = INTSTACK(0);  /* Allow taking addresses of register vars */
 IntStack RegVarsToCallStack = INTSTACK(0);  /* Save reg variables on call stack */
index 8b0af5a83729355f2e9520d4368f1d8a4cc734d2..4ffc84a39f0422b39dcf77f65f31c0b877f4b26a 100644 (file)
@@ -61,7 +61,8 @@ extern unsigned         RegisterSpace;          /* Space available for register
 /* Stackable options */
 extern IntStack         WritableStrings;        /* Literal strings are r/w */
 extern IntStack         LocalStrings;           /* Emit string literals immediately */
-extern IntStack         InlineStdFuncs;         /* Inline some known functions */
+extern IntStack         InlineStdFuncs;         /* Inline some standard functions */
+extern IntStack         EagerlyInlineFuncs;     /* Eagerly inline some known functions */
 extern IntStack         EnableRegVars;          /* Enable register variables */
 extern IntStack         AllowRegVarAddr;        /* Allow taking addresses of register vars */
 extern IntStack         RegVarsToCallStack;     /* Save reg variables on call stack */
index 9ed19b90c99a21e713acd0282eb9e2dcef57d4bd..d3d298876796be344db58dbc29b9881034838fb6 100644 (file)
@@ -88,7 +88,7 @@ static void Usage (void)
             "  -O\t\t\t\tOptimize code\n"
             "  -Oi\t\t\t\tOptimize code, inline more code\n"
             "  -Or\t\t\t\tEnable register variables\n"
-            "  -Os\t\t\t\tInline some known functions\n"
+            "  -Os\t\t\t\tInline some standard functions\n"
             "  -T\t\t\t\tInclude source as comment\n"
             "  -V\t\t\t\tPrint the compiler version number\n"
             "  -W warning[,...]\t\tSuppress warnings\n"
@@ -118,9 +118,11 @@ static void Usage (void)
             "  --debug-opt name\t\tDebug optimization steps\n"
             "  --dep-target target\t\tUse this dependency target\n"
             "  --disable-opt name\t\tDisable an optimization step\n"
+            "  --eagerly-inline-funcs\t\tEagerly inline some known functions\n"
             "  --enable-opt name\t\tEnable an optimization step\n"
             "  --help\t\t\tHelp (this text)\n"
             "  --include-dir dir\t\tSet an include directory search path\n"
+            "  --inline-stdfuncs\t\tInline some standard functions\n"
             "  --list-opt-steps\t\tList all optimizer steps and exit\n"
             "  --list-warnings\t\tList available warning types for -W\n"
             "  --local-strings\t\tEmit string literals immediately\n"
@@ -581,6 +583,16 @@ static void OptDisableOpt (const char* Opt attribute ((unused)), const char* Arg
 
 
 
+static void OptEagerlyInlineFuncs (const char* Opt attribute((unused)),
+                                   const char* Arg attribute((unused)))
+/* Eagerly inline some known functions */
+{
+    IS_Set (&InlineStdFuncs, 1);
+    IS_Set (&EagerlyInlineFuncs, 1);
+}
+
+
+
 static void OptEnableOpt (const char* Opt attribute ((unused)), const char* Arg)
 /* Enable an optimization step */
 {
@@ -608,6 +620,15 @@ static void OptIncludeDir (const char* Opt attribute ((unused)), const char* Arg
 
 
 
+static void OptInlineStdFuncs (const char* Opt attribute((unused)),
+                               const char* Arg attribute((unused)))
+/* Inline some standard functions */
+{
+    IS_Set (&InlineStdFuncs, 1);
+}
+
+
+
 static void OptListOptSteps (const char* Opt attribute ((unused)),
                              const char* Arg attribute ((unused)))
 /* List all optimizer steps */
@@ -819,39 +840,41 @@ int main (int argc, char* argv[])
 {
     /* Program long options */
     static const LongOpt OptTab[] = {
-        { "--add-source",       0,      OptAddSource            },
-        { "--all-cdecl",        0,      OptAllCDecl             },
-        { "--bss-name",         1,      OptBssName              },
-        { "--check-stack",      0,      OptCheckStack           },
-        { "--code-name",        1,      OptCodeName             },
-        { "--codesize",         1,      OptCodeSize             },
-        { "--cpu",              1,      OptCPU                  },
-        { "--create-dep",       1,      OptCreateDep            },
-        { "--create-full-dep",  1,      OptCreateFullDep        },
-        { "--data-name",        1,      OptDataName             },
-        { "--debug",            0,      OptDebug                },
-        { "--debug-info",       0,      OptDebugInfo            },
-        { "--debug-opt",        1,      OptDebugOpt             },
-        { "--debug-opt-output", 0,      OptDebugOptOutput       },
-        { "--dep-target",       1,      OptDepTarget            },
-        { "--disable-opt",      1,      OptDisableOpt           },
-        { "--enable-opt",       1,      OptEnableOpt            },
-        { "--help",             0,      OptHelp                 },
-        { "--include-dir",      1,      OptIncludeDir           },
-        { "--list-opt-steps",   0,      OptListOptSteps         },
-        { "--list-warnings",    0,      OptListWarnings         },
-        { "--local-strings",    0,      OptLocalStrings         },
-        { "--memory-model",     1,      OptMemoryModel          },
-        { "--register-space",   1,      OptRegisterSpace        },
-        { "--register-vars",    0,      OptRegisterVars         },
-        { "--rodata-name",      1,      OptRodataName           },
-        { "--signed-chars",     0,      OptSignedChars          },
-        { "--standard",         1,      OptStandard             },
-        { "--static-locals",    0,      OptStaticLocals         },
-        { "--target",           1,      OptTarget               },
-        { "--verbose",          0,      OptVerbose              },
-        { "--version",          0,      OptVersion              },
-        { "--writable-strings", 0,      OptWritableStrings      },
+        { "--add-source",           0,      OptAddSource            },
+        { "--all-cdecl",            0,      OptAllCDecl             },
+        { "--bss-name",             1,      OptBssName              },
+        { "--check-stack",          0,      OptCheckStack           },
+        { "--code-name",            1,      OptCodeName             },
+        { "--codesize",             1,      OptCodeSize             },
+        { "--cpu",                  1,      OptCPU                  },
+        { "--create-dep",           1,      OptCreateDep            },
+        { "--create-full-dep",      1,      OptCreateFullDep        },
+        { "--data-name",            1,      OptDataName             },
+        { "--debug",                0,      OptDebug                },
+        { "--debug-info",           0,      OptDebugInfo            },
+        { "--debug-opt",            1,      OptDebugOpt             },
+        { "--debug-opt-output",     0,      OptDebugOptOutput       },
+        { "--dep-target",           1,      OptDepTarget            },
+        { "--disable-opt",          1,      OptDisableOpt           },
+        { "--eagerly-inline-funcs", 0,      OptEagerlyInlineFuncs   },
+        { "--enable-opt",           1,      OptEnableOpt            },
+        { "--help",                 0,      OptHelp                 },
+        { "--include-dir",          1,      OptIncludeDir           },
+        { "--inline-stdfuncs",      0,      OptInlineStdFuncs       },
+        { "--list-opt-steps",       0,      OptListOptSteps         },
+        { "--list-warnings",        0,      OptListWarnings         },
+        { "--local-strings",        0,      OptLocalStrings         },
+        { "--memory-model",         1,      OptMemoryModel          },
+        { "--register-space",       1,      OptRegisterSpace        },
+        { "--register-vars",        0,      OptRegisterVars         },
+        { "--rodata-name",          1,      OptRodataName           },
+        { "--signed-chars",         0,      OptSignedChars          },
+        { "--standard",             1,      OptStandard             },
+        { "--static-locals",        0,      OptStaticLocals         },
+        { "--target",               1,      OptTarget               },
+        { "--verbose",              0,      OptVerbose              },
+        { "--version",              0,      OptVersion              },
+        { "--writable-strings",     0,      OptWritableStrings      },
     };
 
     unsigned I;
index 86739ce22887db1bdb8692d5f8740d8be559317d..25bc29d43cdfbfaad8cb6425deaf900c5af46e04 100644 (file)
@@ -51,6 +51,7 @@
 #include "scanstrbuf.h"
 #include "symtab.h"
 #include "pragma.h"
+#include "wrappedcall.h"
 
 
 
@@ -64,6 +65,7 @@
 typedef enum {
     PRAGMA_ILLEGAL = -1,
     PRAGMA_ALIGN,
+    PRAGMA_ALLOW_EAGER_INLINE,
     PRAGMA_BSS_NAME,
     PRAGMA_BSSSEG,                                      /* obsolete */
     PRAGMA_CHARMAP,
@@ -74,10 +76,12 @@ typedef enum {
     PRAGMA_CODESIZE,
     PRAGMA_DATA_NAME,
     PRAGMA_DATASEG,                                     /* obsolete */
+    PRAGMA_INLINE_STDFUNCS,
     PRAGMA_LOCAL_STRINGS,
+    PRAGMA_MESSAGE,
     PRAGMA_OPTIMIZE,
-    PRAGMA_REGVARADDR,
     PRAGMA_REGISTER_VARS,
+    PRAGMA_REGVARADDR,
     PRAGMA_REGVARS,                                     /* obsolete */
     PRAGMA_RODATA_NAME,
     PRAGMA_RODATASEG,                                   /* obsolete */
@@ -86,6 +90,7 @@ typedef enum {
     PRAGMA_STATIC_LOCALS,
     PRAGMA_STATICLOCALS,                                /* obsolete */
     PRAGMA_WARN,
+    PRAGMA_WRAPPED_CALL,
     PRAGMA_WRITABLE_STRINGS,
     PRAGMA_ZPSYM,
     PRAGMA_COUNT
@@ -96,31 +101,35 @@ static const struct Pragma {
     const char* Key;            /* Keyword */
     pragma_t    Tok;            /* Token */
 } Pragmas[PRAGMA_COUNT] = {
-    { "align",                  PRAGMA_ALIGN            },
-    { "bss-name",               PRAGMA_BSS_NAME         },
-    { "bssseg",                 PRAGMA_BSSSEG           },      /* obsolete */
-    { "charmap",                PRAGMA_CHARMAP          },
-    { "check-stack",            PRAGMA_CHECK_STACK      },
-    { "checkstack",             PRAGMA_CHECKSTACK       },      /* obsolete */
-    { "code-name",              PRAGMA_CODE_NAME        },
-    { "codeseg",                PRAGMA_CODESEG          },      /* obsolete */
-    { "codesize",               PRAGMA_CODESIZE         },
-    { "data-name",              PRAGMA_DATA_NAME        },
-    { "dataseg",                PRAGMA_DATASEG          },      /* obsolete */
-    { "local-strings",          PRAGMA_LOCAL_STRINGS    },
-    { "optimize",               PRAGMA_OPTIMIZE         },
-    { "register-vars",          PRAGMA_REGISTER_VARS    },
-    { "regvaraddr",             PRAGMA_REGVARADDR       },
-    { "regvars",                PRAGMA_REGVARS          },      /* obsolete */
-    { "rodata-name",            PRAGMA_RODATA_NAME      },
-    { "rodataseg",              PRAGMA_RODATASEG        },      /* obsolete */
-    { "signed-chars",           PRAGMA_SIGNED_CHARS     },
-    { "signedchars",            PRAGMA_SIGNEDCHARS      },      /* obsolete */
-    { "static-locals",          PRAGMA_STATIC_LOCALS    },
-    { "staticlocals",           PRAGMA_STATICLOCALS     },      /* obsolete */
-    { "warn",                   PRAGMA_WARN             },
-    { "writable-strings",       PRAGMA_WRITABLE_STRINGS },
-    { "zpsym",                  PRAGMA_ZPSYM            },
+    { "align",                  PRAGMA_ALIGN              },
+    { "allow-eager-inline",     PRAGMA_ALLOW_EAGER_INLINE },
+    { "bss-name",               PRAGMA_BSS_NAME           },
+    { "bssseg",                 PRAGMA_BSSSEG             },      /* obsolete */
+    { "charmap",                PRAGMA_CHARMAP            },
+    { "check-stack",            PRAGMA_CHECK_STACK        },
+    { "checkstack",             PRAGMA_CHECKSTACK         },      /* obsolete */
+    { "code-name",              PRAGMA_CODE_NAME          },
+    { "codeseg",                PRAGMA_CODESEG            },      /* obsolete */
+    { "codesize",               PRAGMA_CODESIZE           },
+    { "data-name",              PRAGMA_DATA_NAME          },
+    { "dataseg",                PRAGMA_DATASEG            },      /* obsolete */
+    { "inline-stdfuncs",        PRAGMA_INLINE_STDFUNCS    },
+    { "local-strings",          PRAGMA_LOCAL_STRINGS      },
+    { "message",                PRAGMA_MESSAGE            },
+    { "optimize",               PRAGMA_OPTIMIZE           },
+    { "register-vars",          PRAGMA_REGISTER_VARS      },
+    { "regvaraddr",             PRAGMA_REGVARADDR         },
+    { "regvars",                PRAGMA_REGVARS            },      /* obsolete */
+    { "rodata-name",            PRAGMA_RODATA_NAME        },
+    { "rodataseg",              PRAGMA_RODATASEG          },      /* obsolete */
+    { "signed-chars",           PRAGMA_SIGNED_CHARS       },
+    { "signedchars",            PRAGMA_SIGNEDCHARS        },      /* obsolete */
+    { "static-locals",          PRAGMA_STATIC_LOCALS      },
+    { "staticlocals",           PRAGMA_STATICLOCALS       },      /* obsolete */
+    { "warn",                   PRAGMA_WARN               },
+    { "wrapped-call",           PRAGMA_WRAPPED_CALL       },
+    { "writable-strings",       PRAGMA_WRITABLE_STRINGS   },
+    { "zpsym",                  PRAGMA_ZPSYM              },
 };
 
 /* Result of ParsePushPop */
@@ -379,11 +388,11 @@ static void StringPragma (StrBuf* B, void (*Func) (const char*))
 static void SegNamePragma (StrBuf* B, segment_t Seg)
 /* Handle a pragma that expects a segment name parameter */
 {
-    StrBuf      S = AUTO_STRBUF_INITIALIZER;
     const char* Name;
+    StrBuf S = AUTO_STRBUF_INITIALIZER;
+    int Push = 0;
 
     /* Check for the "push" or "pop" keywords */
-    int Push = 0;
     switch (ParsePushPop (B)) {
 
         case PP_NONE:
@@ -396,7 +405,13 @@ static void SegNamePragma (StrBuf* B, segment_t Seg)
         case PP_POP:
             /* Pop the old value and output it */
             PopSegName (Seg);
-            g_segname (Seg);
+
+            /* BSS variables are output at the end of the compilation.  Don't
+            ** bother to change their segment, now.
+            */
+            if (Seg != SEG_BSS) {
+                g_segname (Seg);
+            }
 
             /* Done */
             goto ExitPoint;
@@ -427,7 +442,13 @@ static void SegNamePragma (StrBuf* B, segment_t Seg)
         } else {
             SetSegName (Seg, Name);
         }
-        g_segname (Seg);
+
+        /* BSS variables are output at the end of the compilation.  Don't
+        ** bother to change their segment, now.
+        */
+        if (Seg != SEG_BSS) {
+            g_segname (Seg);
+        }
 
     } else {
 
@@ -442,6 +463,85 @@ ExitPoint:
 }
 
 
+static void WrappedCallPragma (StrBuf* B)
+/* Handle the wrapped-call pragma */
+{
+    StrBuf      S = AUTO_STRBUF_INITIALIZER;
+    const char *Name;
+    long Val;
+    SymEntry *Entry;
+
+    /* Check for the "push" or "pop" keywords */
+    switch (ParsePushPop (B)) {
+
+        case PP_NONE:
+            Error ("Push or pop required");
+            break;
+
+        case PP_PUSH:
+            break;
+
+        case PP_POP:
+            PopWrappedCall();
+
+            /* Done */
+            goto ExitPoint;
+
+        case PP_ERROR:
+            /* Bail out */
+            goto ExitPoint;
+
+        default:
+            Internal ("Invalid result from ParsePushPop");
+
+    }
+
+    /* A symbol argument must follow */
+    if (!SB_GetSym (B, &S, NULL)) {
+        goto ExitPoint;
+    }
+
+    /* Skip the following comma */
+    if (!GetComma (B)) {
+        /* Error already flagged by GetComma */
+        Error ("Value required for wrapped-call identifier");
+        goto ExitPoint;
+    }
+
+    if (!GetNumber (B, &Val)) {
+        Error ("Value required for wrapped-call identifier");
+        goto ExitPoint;
+    }
+
+    if (Val < 0 || Val > 255) {
+        Error ("Identifier must be between 0-255");
+        goto ExitPoint;
+    }
+
+    /* Get the string */
+    Name = SB_GetConstBuf (&S);
+    Entry = FindSym(Name);
+
+    /* Check if the name is valid */
+    if (Entry && Entry->Flags & SC_FUNC) {
+
+        PushWrappedCall(Entry, Val);
+        Entry->Flags |= SC_REF;
+        Entry->V.F.Func->Flags |= FD_CALL_WRAPPER;
+
+    } else {
+
+        /* Segment name is invalid */
+        Error ("Wrapped-call target does not exist or is not a function");
+
+    }
+
+ExitPoint:
+    /* Call the string buf destructor */
+    SB_Done (&S);
+}
+
+
 
 static void CharMapPragma (StrBuf* B)
 /* Change the character map */
@@ -652,6 +752,13 @@ static void IntPragma (StrBuf* B, IntStack* Stack, long Low, long High)
 
 
 
+static void MakeMessage (const char* Message)
+{
+    fprintf (stderr, "%s(%u): Note: %s\n", GetInputName (CurTok.LI), GetInputLine (CurTok.LI), Message);
+}
+
+
+
 static void ParsePragma (void)
 /* Parse the contents of the _Pragma statement */
 {
@@ -703,6 +810,10 @@ static void ParsePragma (void)
             IntPragma (&B, &DataAlignment, 1, 4096);
             break;
 
+        case PRAGMA_ALLOW_EAGER_INLINE:
+            FlagPragma (&B, &EagerlyInlineFuncs);
+            break;
+
         case PRAGMA_BSSSEG:
             Warning ("#pragma bssseg is obsolete, please use #pragma bss-name instead");
             /* FALLTHROUGH */
@@ -739,10 +850,18 @@ static void ParsePragma (void)
             SegNamePragma (&B, SEG_DATA);
             break;
 
+        case PRAGMA_INLINE_STDFUNCS:
+            FlagPragma (&B, &InlineStdFuncs);
+            break;
+
         case PRAGMA_LOCAL_STRINGS:
             FlagPragma (&B, &LocalStrings);
             break;
 
+        case PRAGMA_MESSAGE:
+            StringPragma (&B, MakeMessage);
+            break;
+
         case PRAGMA_OPTIMIZE:
             FlagPragma (&B, &Optimize);
             break;
@@ -779,6 +898,10 @@ static void ParsePragma (void)
             FlagPragma (&B, &StaticLocals);
             break;
 
+       case PRAGMA_WRAPPED_CALL:
+           WrappedCallPragma(&B);
+           break;
+
         case PRAGMA_WARN:
             WarnPragma (&B);
             break;
index 36897a059b9b72f989bc1e5d74e2f3eb507e47cf..f26b63c20b3c88e8c6a2765afa964586a5d8bf5b 100644 (file)
@@ -50,7 +50,7 @@
 IntStack Standard           = INTSTACK(STD_UNKNOWN);
 
 /* Table mapping names to standards, sorted by standard. */
-static const char* StdNames[STD_COUNT] = {
+static const char* const StdNames[STD_COUNT] = {
     "c89", "c99", "cc65"
 };
 
index 720e6db15fdcac43c8980c31b1734067726c7685..2d4317ef87e86cfc204f21a809dbbb7b3ea94116 100644 (file)
@@ -261,262 +261,277 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
         goto ExitPoint;
     }
 
-    /* We've generated the complete code for the function now and know the
-    ** types of all parameters. Check for situations where better code can
-    ** be generated. If such a situation is detected, throw away the
-    ** generated, and emit better code.
-    */
-    if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 &&
-        ((ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr)) ||
-         (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr))) &&
-        ((ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) ||
-         (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr)))) {
+    if (IS_Get (&InlineStdFuncs)) {
 
-        int Reg1 = ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr);
-        int Reg2 = ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr);
+        /* We've generated the complete code for the function now and know the
+        ** types of all parameters. Check for situations where better code can
+        ** be generated. If such a situation is detected, throw away the
+        ** generated, and emit better code.
+        */
+        if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 &&
+            ((ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr)) ||
+             (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr))) &&
+            ((ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) ||
+             (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr)))) {
 
-        /* Drop the generated code */
-        RemoveCode (&Arg1.Expr.Start);
+            int Reg1 = ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr);
+            int Reg2 = ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr);
 
-        /* We need a label */
-        Label = GetLocalLabel ();
+            /* Drop the generated code */
+            RemoveCode (&Arg1.Expr.Start);
 
-        /* Generate memcpy code */
-        if (Arg3.Expr.IVal <= 127) {
+            /* We need a label */
+            Label = GetLocalLabel ();
 
-            AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1));
-            g_defcodelabel (Label);
-            if (Reg2) {
-                AddCodeLine ("lda (%s),y", ED_GetLabelName (&Arg2.Expr, 0));
-            } else {
-                AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, 0));
-            }
-            if (Reg1) {
-                AddCodeLine ("sta (%s),y", ED_GetLabelName (&Arg1.Expr, 0));
-            } else {
-                AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0));
-            }
-            AddCodeLine ("dey");
-            AddCodeLine ("bpl %s", LocalLabelName (Label));
+            /* Generate memcpy code */
+            if (Arg3.Expr.IVal <= 129) {
 
-        } else {
+                AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1));
+                g_defcodelabel (Label);
+                if (Reg2) {
+                    AddCodeLine ("lda (%s),y", ED_GetLabelName (&Arg2.Expr, 0));
+                } else {
+                    AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, 0));
+                }
+                if (Reg1) {
+                    AddCodeLine ("sta (%s),y", ED_GetLabelName (&Arg1.Expr, 0));
+                } else {
+                    AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0));
+                }
+                AddCodeLine ("dey");
+                AddCodeLine ("bpl %s", LocalLabelName (Label));
 
-            AddCodeLine ("ldy #$00");
-            g_defcodelabel (Label);
-            if (Reg2) {
-                AddCodeLine ("lda (%s),y", ED_GetLabelName (&Arg2.Expr, 0));
-            } else {
-                AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, 0));
-            }
-            if (Reg1) {
-                AddCodeLine ("sta (%s),y", ED_GetLabelName (&Arg1.Expr, 0));
             } else {
-                AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0));
-            }
-            AddCodeLine ("iny");
-            AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal);
-            AddCodeLine ("bne %s", LocalLabelName (Label));
 
-        }
+                AddCodeLine ("ldy #$00");
+                g_defcodelabel (Label);
+                if (Reg2) {
+                    AddCodeLine ("lda (%s),y", ED_GetLabelName (&Arg2.Expr, 0));
+                } else {
+                    AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, 0));
+                }
+                if (Reg1) {
+                    AddCodeLine ("sta (%s),y", ED_GetLabelName (&Arg1.Expr, 0));
+                } else {
+                    AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0));
+                }
+                AddCodeLine ("iny");
+                AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal);
+                AddCodeLine ("bne %s", LocalLabelName (Label));
 
-        /* memcpy returns the address, so the result is actually identical
-        ** to the first argument.
-        */
-        *Expr = Arg1.Expr;
+            }
 
-    } else if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 &&
-               ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr) &&
-               ED_IsRVal (&Arg1.Expr) && ED_IsLocStack (&Arg1.Expr) &&
-               (Arg1.Expr.IVal - StackPtr) + Arg3.Expr.IVal < 256) {
-
-        /* It is possible to just use one index register even if the stack
-        ** offset is not zero, by adjusting the offset to the constant
-        ** address accordingly. But we cannot do this if the data in
-        ** question is in the register space or at an absolute address less
-        ** than 256. Register space is zero page, which means that the
-        ** address calculation could overflow in the linker.
-        */
-        int AllowOneIndex = !ED_IsLocRegister (&Arg2.Expr) &&
-                            !(ED_IsLocAbs (&Arg2.Expr) && Arg2.Expr.IVal < 256);
+            /* memcpy returns the address, so the result is actually identical
+            ** to the first argument.
+            */
+            *Expr = Arg1.Expr;
 
-        /* Calculate the real stack offset */
-        Offs = ED_GetStackOffs (&Arg1.Expr, 0);
+            /* Bail out, no need for further processing */
+            goto ExitPoint;
+        }
 
-        /* Drop the generated code */
-        RemoveCode (&Arg1.Expr.Start);
+        if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 &&
+            ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr) &&
+            ED_IsRVal (&Arg1.Expr) && ED_IsLocStack (&Arg1.Expr) &&
+            (Arg1.Expr.IVal - StackPtr) + Arg3.Expr.IVal < 256) {
+
+            /* It is possible to just use one index register even if the stack
+            ** offset is not zero, by adjusting the offset to the constant
+            ** address accordingly. But we cannot do this if the data in
+            ** question is in the register space or at an absolute address less
+            ** than 256. Register space is zero page, which means that the
+            ** address calculation could overflow in the linker.
+            */
+            int AllowOneIndex = !ED_IsLocRegister (&Arg2.Expr) &&
+                                !(ED_IsLocAbs (&Arg2.Expr) && Arg2.Expr.IVal < 256);
 
-        /* We need a label */
-        Label = GetLocalLabel ();
+            /* Calculate the real stack offset */
+            Offs = ED_GetStackOffs (&Arg1.Expr, 0);
 
-        /* Generate memcpy code */
-        if (Arg3.Expr.IVal <= 127 && !AllowOneIndex) {
+            /* Drop the generated code */
+            RemoveCode (&Arg1.Expr.Start);
+
+            /* We need a label */
+            Label = GetLocalLabel ();
+
+            /* Generate memcpy code */
+            if (Arg3.Expr.IVal <= 129 && !AllowOneIndex) {
+
+                if (Offs == 0) {
+                    AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1));
+                    g_defcodelabel (Label);
+                    AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs));
+                    AddCodeLine ("sta (sp),y");
+                    AddCodeLine ("dey");
+                    AddCodeLine ("bpl %s", LocalLabelName (Label));
+                } else {
+                    AddCodeLine ("ldx #$%02X", (unsigned char) (Arg3.Expr.IVal-1));
+                    AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1));
+                    g_defcodelabel (Label);
+                    AddCodeLine ("lda %s,x", ED_GetLabelName (&Arg2.Expr, 0));
+                    AddCodeLine ("sta (sp),y");
+                    AddCodeLine ("dey");
+                    AddCodeLine ("dex");
+                    AddCodeLine ("bpl %s", LocalLabelName (Label));
+                }
 
-            if (Offs == 0) {
-                AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1));
-                g_defcodelabel (Label);
-                AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs));
-                AddCodeLine ("sta (sp),y");
-                AddCodeLine ("dey");
-                AddCodeLine ("bpl %s", LocalLabelName (Label));
             } else {
-                AddCodeLine ("ldx #$%02X", (unsigned char) (Arg3.Expr.IVal-1));
-                AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1));
-                g_defcodelabel (Label);
-                AddCodeLine ("lda %s,x", ED_GetLabelName (&Arg2.Expr, 0));
-                AddCodeLine ("sta (sp),y");
-                AddCodeLine ("dey");
-                AddCodeLine ("dex");
-                AddCodeLine ("bpl %s", LocalLabelName (Label));
-            }
 
-        } else {
+                if (Offs == 0 || AllowOneIndex) {
+                    AddCodeLine ("ldy #$%02X", (unsigned char) Offs);
+                    g_defcodelabel (Label);
+                    AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs));
+                    AddCodeLine ("sta (sp),y");
+                    AddCodeLine ("iny");
+                    AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal);
+                    AddCodeLine ("bne %s", LocalLabelName (Label));
+                } else {
+                    AddCodeLine ("ldx #$00");
+                    AddCodeLine ("ldy #$%02X", (unsigned char) Offs);
+                    g_defcodelabel (Label);
+                    AddCodeLine ("lda %s,x", ED_GetLabelName (&Arg2.Expr, 0));
+                    AddCodeLine ("sta (sp),y");
+                    AddCodeLine ("iny");
+                    AddCodeLine ("inx");
+                    AddCmpCodeIfSizeNot256 ("cpx #$%02X", Arg3.Expr.IVal);
+                    AddCodeLine ("bne %s", LocalLabelName (Label));
+                }
 
-            if (Offs == 0 || AllowOneIndex) {
-                AddCodeLine ("ldy #$%02X", (unsigned char) Offs);
-                g_defcodelabel (Label);
-                AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs));
-                AddCodeLine ("sta (sp),y");
-                AddCodeLine ("iny");
-                AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal);
-                AddCodeLine ("bne %s", LocalLabelName (Label));
-            } else {
-                AddCodeLine ("ldx #$00");
-                AddCodeLine ("ldy #$%02X", (unsigned char) Offs);
-                g_defcodelabel (Label);
-                AddCodeLine ("lda %s,x", ED_GetLabelName (&Arg2.Expr, 0));
-                AddCodeLine ("sta (sp),y");
-                AddCodeLine ("iny");
-                AddCodeLine ("inx");
-                AddCmpCodeIfSizeNot256 ("cpx #$%02X", Arg3.Expr.IVal);
-                AddCodeLine ("bne %s", LocalLabelName (Label));
             }
 
+            /* memcpy returns the address, so the result is actually identical
+            ** to the first argument.
+            */
+            *Expr = Arg1.Expr;
+
+            /* Bail out, no need for further processing */
+            goto ExitPoint;
         }
 
-        /* memcpy returns the address, so the result is actually identical
-        ** to the first argument.
-        */
-        *Expr = Arg1.Expr;
+        if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 &&
+            ED_IsRVal (&Arg2.Expr) && ED_IsLocStack (&Arg2.Expr) &&
+            (Arg2.Expr.IVal - StackPtr) + Arg3.Expr.IVal < 256 &&
+            ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) {
+
+            /* It is possible to just use one index register even if the stack
+            ** offset is not zero, by adjusting the offset to the constant
+            ** address accordingly. But we cannot do this if the data in
+            ** question is in the register space or at an absolute address less
+            ** than 256. Register space is zero page, which means that the
+            ** address calculation could overflow in the linker.
+            */
+            int AllowOneIndex = !ED_IsLocRegister (&Arg1.Expr) &&
+                                !(ED_IsLocAbs (&Arg1.Expr) && Arg1.Expr.IVal < 256);
 
-    } else if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 &&
-               ED_IsRVal (&Arg2.Expr) && ED_IsLocStack (&Arg2.Expr) &&
-               (Arg2.Expr.IVal - StackPtr) + Arg3.Expr.IVal < 256 &&
-               ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) {
-
-        /* It is possible to just use one index register even if the stack
-        ** offset is not zero, by adjusting the offset to the constant
-        ** address accordingly. But we cannot do this if the data in
-        ** question is in the register space or at an absolute address less
-        ** than 256. Register space is zero page, which means that the
-        ** address calculation could overflow in the linker.
-        */
-        int AllowOneIndex = !ED_IsLocRegister (&Arg1.Expr) &&
-                            !(ED_IsLocAbs (&Arg1.Expr) && Arg1.Expr.IVal < 256);
+            /* Calculate the real stack offset */
+            Offs = ED_GetStackOffs (&Arg2.Expr, 0);
+
+            /* Drop the generated code */
+            RemoveCode (&Arg1.Expr.Start);
+
+            /* We need a label */
+            Label = GetLocalLabel ();
+
+            /* Generate memcpy code */
+            if (Arg3.Expr.IVal <= 129 && !AllowOneIndex) {
+
+                if (Offs == 0) {
+                    AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal - 1));
+                    g_defcodelabel (Label);
+                    AddCodeLine ("lda (sp),y");
+                    AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0));
+                    AddCodeLine ("dey");
+                    AddCodeLine ("bpl %s", LocalLabelName (Label));
+                } else {
+                    AddCodeLine ("ldx #$%02X", (unsigned char) (Arg3.Expr.IVal-1));
+                    AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1));
+                    g_defcodelabel (Label);
+                    AddCodeLine ("lda (sp),y");
+                    AddCodeLine ("sta %s,x", ED_GetLabelName (&Arg1.Expr, 0));
+                    AddCodeLine ("dey");
+                    AddCodeLine ("dex");
+                    AddCodeLine ("bpl %s", LocalLabelName (Label));
+                }
+
+            } else {
+
+                if (Offs == 0 || AllowOneIndex) {
+                    AddCodeLine ("ldy #$%02X", (unsigned char) Offs);
+                    g_defcodelabel (Label);
+                    AddCodeLine ("lda (sp),y");
+                    AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, -Offs));
+                    AddCodeLine ("iny");
+                    AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal);
+                    AddCodeLine ("bne %s", LocalLabelName (Label));
+                } else {
+                    AddCodeLine ("ldx #$00");
+                    AddCodeLine ("ldy #$%02X", (unsigned char) Offs);
+                    g_defcodelabel (Label);
+                    AddCodeLine ("lda (sp),y");
+                    AddCodeLine ("sta %s,x", ED_GetLabelName (&Arg1.Expr, 0));
+                    AddCodeLine ("iny");
+                    AddCodeLine ("inx");
+                    AddCmpCodeIfSizeNot256 ("cpx #$%02X", Arg3.Expr.IVal);
+                    AddCodeLine ("bne %s", LocalLabelName (Label));
+                }
 
-        /* Calculate the real stack offset */
-        Offs = ED_GetStackOffs (&Arg2.Expr, 0);
+            }
 
-        /* Drop the generated code */
-        RemoveCode (&Arg1.Expr.Start);
+            /* memcpy returns the address, so the result is actually identical
+            ** to the first argument.
+            */
+            *Expr = Arg1.Expr;
 
-        /* We need a label */
-        Label = GetLocalLabel ();
+            /* Bail out, no need for further processing */
+            goto ExitPoint;
+        }
 
-        /* Generate memcpy code */
-        if (Arg3.Expr.IVal <= 127 && !AllowOneIndex) {
+        if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256   &&
+            ED_IsRVal (&Arg2.Expr) && ED_IsLocStack (&Arg2.Expr)     &&
+            (Offs = ED_GetStackOffs (&Arg2.Expr, 0)) == 0) {
 
-            if (Offs == 0) {
+            /* Drop the generated code but leave the load of the first argument*/
+            RemoveCode (&Arg1.Push);
+
+            /* We need a label */
+            Label = GetLocalLabel ();
+
+            /* Generate memcpy code */
+            AddCodeLine ("sta ptr1");
+            AddCodeLine ("stx ptr1+1");
+            if (Arg3.Expr.IVal <= 129) {
                 AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal - 1));
                 g_defcodelabel (Label);
                 AddCodeLine ("lda (sp),y");
-                AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0));
+                AddCodeLine ("sta (ptr1),y");
                 AddCodeLine ("dey");
                 AddCodeLine ("bpl %s", LocalLabelName (Label));
             } else {
-                AddCodeLine ("ldx #$%02X", (unsigned char) (Arg3.Expr.IVal-1));
-                AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1));
+                AddCodeLine ("ldy #$00");
                 g_defcodelabel (Label);
                 AddCodeLine ("lda (sp),y");
-                AddCodeLine ("sta %s,x", ED_GetLabelName (&Arg1.Expr, 0));
-                AddCodeLine ("dey");
-                AddCodeLine ("dex");
-                AddCodeLine ("bpl %s", LocalLabelName (Label));
-            }
-
-        } else {
-
-            if (Offs == 0 || AllowOneIndex) {
-                AddCodeLine ("ldy #$%02X", (unsigned char) Offs);
-                g_defcodelabel (Label);
-                AddCodeLine ("lda (sp),y");
-                AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, -Offs));
+                AddCodeLine ("sta (ptr1),y");
                 AddCodeLine ("iny");
-                AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal);
-                AddCodeLine ("bne %s", LocalLabelName (Label));
-            } else {
-                AddCodeLine ("ldx #$00");
-                AddCodeLine ("ldy #$%02X", (unsigned char) Offs);
-                g_defcodelabel (Label);
-                AddCodeLine ("lda (sp),y");
-                AddCodeLine ("sta %s,x", ED_GetLabelName (&Arg1.Expr, 0));
-                AddCodeLine ("iny");
-                AddCodeLine ("inx");
-                AddCmpCodeIfSizeNot256 ("cpx #$%02X", Arg3.Expr.IVal);
+                AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal);
                 AddCodeLine ("bne %s", LocalLabelName (Label));
             }
 
-        }
+            /* Reload result - X hasn't changed by the code above */
+            AddCodeLine ("lda ptr1");
 
-        /* memcpy returns the address, so the result is actually identical
-        ** to the first argument.
-        */
-        *Expr = Arg1.Expr;
-
-    } else if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256   &&
-               ED_IsRVal (&Arg2.Expr) && ED_IsLocStack (&Arg2.Expr)     &&
-               (Offs = ED_GetStackOffs (&Arg2.Expr, 0)) == 0) {
-
-        /* Drop the generated code but leave the load of the first argument*/
-        RemoveCode (&Arg1.Push);
+            /* The function result is an rvalue in the primary register */
+            ED_MakeRValExpr (Expr);
+            Expr->Type = GetFuncReturn (Expr->Type);
 
-        /* We need a label */
-        Label = GetLocalLabel ();
-
-        /* Generate memcpy code */
-        AddCodeLine ("sta ptr1");
-        AddCodeLine ("stx ptr1+1");
-        if (Arg3.Expr.IVal <= 127) {
-            AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal - 1));
-            g_defcodelabel (Label);
-            AddCodeLine ("lda (sp),y");
-            AddCodeLine ("sta (ptr1),y");
-            AddCodeLine ("dey");
-            AddCodeLine ("bpl %s", LocalLabelName (Label));
-        } else {
-            AddCodeLine ("ldy #$00");
-            g_defcodelabel (Label);
-            AddCodeLine ("lda (sp),y");
-            AddCodeLine ("sta (ptr1),y");
-            AddCodeLine ("iny");
-            AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal);
-            AddCodeLine ("bne %s", LocalLabelName (Label));
+            /* Bail out, no need for further processing */
+            goto ExitPoint;
         }
-
-        /* Reload result - X hasn't changed by the code above */
-        AddCodeLine ("lda ptr1");
-
-        /* The function result is an rvalue in the primary register */
-        ED_MakeRValExpr (Expr);
-        Expr->Type = GetFuncReturn (Expr->Type);
-
-    } else {
-
-        /* The function result is an rvalue in the primary register */
-        ED_MakeRValExpr (Expr);
-        Expr->Type = GetFuncReturn (Expr->Type);
-
     }
 
+    /* The function result is an rvalue in the primary register */
+    ED_MakeRValExpr (Expr);
+    Expr->Type = GetFuncReturn (Expr->Type);
+
 ExitPoint:
     /* We expect the closing brace */
     ConsumeRParen ();
@@ -595,140 +610,151 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
         goto ExitPoint;
     }
 
-    /* We've generated the complete code for the function now and know the
-    ** types of all parameters. Check for situations where better code can
-    ** be generated. If such a situation is detected, throw away the
-    ** generated, and emit better code.
-    ** Note: Lots of improvements would be possible here, but I will
-    ** concentrate on the most common case: memset with arguments 2 and 3
-    ** being constant numerical values. Some checks have shown that this
-    ** covers nearly 90% of all memset calls.
-    */
-    if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 &&
-        ED_IsConstAbsInt (&Arg2.Expr) &&
-        ((ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) ||
-         (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr)))) {
+    if (IS_Get (&InlineStdFuncs)) {
 
-        int Reg = ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr);
+        /* We've generated the complete code for the function now and know the
+        ** types of all parameters. Check for situations where better code can
+        ** be generated. If such a situation is detected, throw away the
+        ** generated, and emit better code.
+        ** Note: Lots of improvements would be possible here, but I will
+        ** concentrate on the most common case: memset with arguments 2 and 3
+        ** being constant numerical values. Some checks have shown that this
+        ** covers nearly 90% of all memset calls.
+        */
+        if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 &&
+            ED_IsConstAbsInt (&Arg2.Expr) &&
+            ((ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) ||
+             (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr)))) {
 
-        /* Drop the generated code */
-        RemoveCode (&Arg1.Expr.Start);
+            int Reg = ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr);
 
-        /* We need a label */
-        Label = GetLocalLabel ();
+            /* Drop the generated code */
+            RemoveCode (&Arg1.Expr.Start);
 
-        /* Generate memset code */
-        if (Arg3.Expr.IVal <= 127) {
+            /* We need a label */
+            Label = GetLocalLabel ();
 
-            AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1));
-            AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal);
-            g_defcodelabel (Label);
-            if (Reg) {
-                AddCodeLine ("sta (%s),y", ED_GetLabelName (&Arg1.Expr, 0));
-            } else {
-                AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0));
-            }
-            AddCodeLine ("dey");
-            AddCodeLine ("bpl %s", LocalLabelName (Label));
+            /* Generate memset code */
+            if (Arg3.Expr.IVal <= 129) {
 
-        } else {
+                AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1));
+                AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal);
+                g_defcodelabel (Label);
+                if (Reg) {
+                    AddCodeLine ("sta (%s),y", ED_GetLabelName (&Arg1.Expr, 0));
+                } else {
+                    AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0));
+                }
+                AddCodeLine ("dey");
+                AddCodeLine ("bpl %s", LocalLabelName (Label));
 
-            AddCodeLine ("ldy #$00");
-            AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal);
-            g_defcodelabel (Label);
-            if (Reg) {
-                AddCodeLine ("sta (%s),y", ED_GetLabelName (&Arg1.Expr, 0));
             } else {
-                AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0));
-            }
-            AddCodeLine ("iny");
-            AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal);
-            AddCodeLine ("bne %s", LocalLabelName (Label));
 
-        }
-
-        /* memset returns the address, so the result is actually identical
-        ** to the first argument.
-        */
-        *Expr = Arg1.Expr;
-
-    } else if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 &&
-               ED_IsConstAbsInt (&Arg2.Expr) &&
-               ED_IsRVal (&Arg1.Expr) && ED_IsLocStack (&Arg1.Expr) &&
-               (Arg1.Expr.IVal - StackPtr) + Arg3.Expr.IVal < 256) {
-
-        /* Calculate the real stack offset */
-        int Offs = ED_GetStackOffs (&Arg1.Expr, 0);
+                AddCodeLine ("ldy #$00");
+                AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal);
+                g_defcodelabel (Label);
+                if (Reg) {
+                    AddCodeLine ("sta (%s),y", ED_GetLabelName (&Arg1.Expr, 0));
+                } else {
+                    AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0));
+                }
+                AddCodeLine ("iny");
+                AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal);
+                AddCodeLine ("bne %s", LocalLabelName (Label));
 
-        /* Drop the generated code */
-        RemoveCode (&Arg1.Expr.Start);
+            }
 
-        /* We need a label */
-        Label = GetLocalLabel ();
+            /* memset returns the address, so the result is actually identical
+            ** to the first argument.
+            */
+            *Expr = Arg1.Expr;
 
-        /* Generate memset code */
-        AddCodeLine ("ldy #$%02X", (unsigned char) Offs);
-        AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal);
-        g_defcodelabel (Label);
-        AddCodeLine ("sta (sp),y");
-        AddCodeLine ("iny");
-        AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal);
-        AddCodeLine ("bne %s", LocalLabelName (Label));
+            /* Bail out, no need for further processing */
+            goto ExitPoint;
+        }
 
-        /* memset returns the address, so the result is actually identical
-        ** to the first argument.
-        */
-        *Expr = Arg1.Expr;
+        if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 &&
+            ED_IsConstAbsInt (&Arg2.Expr) &&
+            ED_IsRVal (&Arg1.Expr) && ED_IsLocStack (&Arg1.Expr) &&
+            (Arg1.Expr.IVal - StackPtr) + Arg3.Expr.IVal < 256) {
 
-    } else if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 &&
-               ED_IsConstAbsInt (&Arg2.Expr) &&
-               (Arg2.Expr.IVal != 0 || IS_Get (&CodeSizeFactor) > 200)) {
+            /* Calculate the real stack offset */
+            int Offs = ED_GetStackOffs (&Arg1.Expr, 0);
 
-        /* Remove all of the generated code but the load of the first
-        ** argument.
-        */
-        RemoveCode (&Arg1.Push);
+            /* Drop the generated code */
+            RemoveCode (&Arg1.Expr.Start);
 
-        /* We need a label */
-        Label = GetLocalLabel ();
+            /* We need a label */
+            Label = GetLocalLabel ();
 
-        /* Generate code */
-        AddCodeLine ("sta ptr1");
-        AddCodeLine ("stx ptr1+1");
-        if (Arg3.Expr.IVal <= 127) {
-            AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1));
+            /* Generate memset code */
+            AddCodeLine ("ldy #$%02X", (unsigned char) Offs);
             AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal);
             g_defcodelabel (Label);
-            AddCodeLine ("sta (ptr1),y");
-            AddCodeLine ("dey");
-            AddCodeLine ("bpl %s", LocalLabelName (Label));
-        } else {
-            AddCodeLine ("ldy #$00");
-            AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal);
-            g_defcodelabel (Label);
-            AddCodeLine ("sta (ptr1),y");
+            AddCodeLine ("sta (sp),y");
             AddCodeLine ("iny");
-            AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal);
+            AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal);
             AddCodeLine ("bne %s", LocalLabelName (Label));
+
+            /* memset returns the address, so the result is actually identical
+            ** to the first argument.
+            */
+            *Expr = Arg1.Expr;
+
+            /* Bail out, no need for further processing */
+            goto ExitPoint;
         }
 
-        /* Load the function result pointer into a/x (x is still valid). This
-        ** code will get removed by the optimizer if it is not used later.
-        */
-        AddCodeLine ("lda ptr1");
+        if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 &&
+            ED_IsConstAbsInt (&Arg2.Expr) &&
+            (Arg2.Expr.IVal != 0 || IS_Get (&CodeSizeFactor) > 200)) {
 
-        /* The function result is an rvalue in the primary register */
-        ED_MakeRValExpr (Expr);
-        Expr->Type = GetFuncReturn (Expr->Type);
+            /* Remove all of the generated code but the load of the first
+            ** argument.
+            */
+            RemoveCode (&Arg1.Push);
 
-    } else {
+            /* We need a label */
+            Label = GetLocalLabel ();
+
+            /* Generate code */
+            AddCodeLine ("sta ptr1");
+            AddCodeLine ("stx ptr1+1");
+            if (Arg3.Expr.IVal <= 129) {
+                AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1));
+                AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal);
+                g_defcodelabel (Label);
+                AddCodeLine ("sta (ptr1),y");
+                AddCodeLine ("dey");
+                AddCodeLine ("bpl %s", LocalLabelName (Label));
+            } else {
+                AddCodeLine ("ldy #$00");
+                AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal);
+                g_defcodelabel (Label);
+                AddCodeLine ("sta (ptr1),y");
+                AddCodeLine ("iny");
+                AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal);
+                AddCodeLine ("bne %s", LocalLabelName (Label));
+            }
 
-        /* The function result is an rvalue in the primary register */
-        ED_MakeRValExpr (Expr);
-        Expr->Type = GetFuncReturn (Expr->Type);
+            /* Load the function result pointer into a/x (x is still valid). This
+            ** code will get removed by the optimizer if it is not used later.
+            */
+            AddCodeLine ("lda ptr1");
+
+            /* The function result is an rvalue in the primary register */
+            ED_MakeRValExpr (Expr);
+            Expr->Type = GetFuncReturn (Expr->Type);
 
+            /* Bail out, no need for further processing */
+            goto ExitPoint;
+        }
     }
 
+    /* The function result is an rvalue in the primary register */
+    ED_MakeRValExpr (Expr);
+    Expr->Type = GetFuncReturn (Expr->Type);
+
 ExitPoint:
     /* We expect the closing brace */
     ConsumeRParen ();
@@ -790,142 +816,142 @@ static void StdFunc_strcmp (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
         ECount1 = ECount2;
     }
 
-    /* If the second argument is the empty string literal, we can generate
-    ** more efficient code.
-    */
-    if (ED_IsLocLiteral (&Arg2.Expr) &&
-        IS_Get (&WritableStrings) == 0 &&
-        GetLiteralSize (Arg2.Expr.LVal) == 1 &&
-        GetLiteralStr (Arg2.Expr.LVal)[0] == '\0') {
+    if (IS_Get (&InlineStdFuncs)) {
 
-        /* Drop the generated code so we have the first argument in the
-        ** primary
+        /* If the second argument is the empty string literal, we can generate
+        ** more efficient code.
         */
-        RemoveCode (&Arg1.Push);
+        if (ED_IsLocLiteral (&Arg2.Expr) &&
+            IS_Get (&WritableStrings) == 0 &&
+            GetLiteralSize (Arg2.Expr.LVal) == 1 &&
+            GetLiteralStr (Arg2.Expr.LVal)[0] == '\0') {
 
-        /* We don't need the literal any longer */
-        ReleaseLiteral (Arg2.Expr.LVal);
-
-        /* We do now have Arg1 in the primary. Load the first character from
-        ** this string and cast to int. This is the function result.
-        */
-        IsArray = IsTypeArray (Arg1.Type) && ED_IsRVal (&Arg1.Expr);
-        if (IsArray && ED_IsLocStack (&Arg1.Expr) &&
-            (Offs = ED_GetStackOffs (&Arg1.Expr, 0) < 256)) {
-            /* Drop the generated code */
-            RemoveCode (&Arg1.Load);
+            /* Drop the generated code so we have the first argument in the
+            ** primary
+            */
+            RemoveCode (&Arg1.Push);
 
-            /* Generate code */
-            AddCodeLine ("ldy #$%02X", Offs);
-            AddCodeLine ("ldx #$00");
-            AddCodeLine ("lda (sp),y");
-        } else if (IsArray && ED_IsLocConst (&Arg1.Expr)) {
-            /* Drop the generated code */
-            RemoveCode (&Arg1.Load);
+            /* We don't need the literal any longer */
+            ReleaseLiteral (Arg2.Expr.LVal);
 
-            /* Generate code */
-            AddCodeLine ("ldx #$00");
-            AddCodeLine ("lda %s", ED_GetLabelName (&Arg1.Expr, 0));
-        } else {
-            /* Drop part of the generated code so we have the first argument
-            ** in the primary
+            /* We do now have Arg1 in the primary. Load the first character from
+            ** this string and cast to int. This is the function result.
             */
-            RemoveCode (&Arg1.Push);
+            IsArray = IsTypeArray (Arg1.Type) && ED_IsRVal (&Arg1.Expr);
+            if (IsArray && ED_IsLocStack (&Arg1.Expr) &&
+                (Offs = ED_GetStackOffs (&Arg1.Expr, 0) < 256)) {
+                /* Drop the generated code */
+                RemoveCode (&Arg1.Load);
+
+                /* Generate code */
+                AddCodeLine ("ldy #$%02X", Offs);
+                AddCodeLine ("ldx #$00");
+                AddCodeLine ("lda (sp),y");
+            } else if (IsArray && ED_IsLocConst (&Arg1.Expr)) {
+                /* Drop the generated code */
+                RemoveCode (&Arg1.Load);
 
-            /* Fetch the first char */
-            g_getind (CF_CHAR | CF_UNSIGNED, 0);
-        }
+                /* Generate code */
+                AddCodeLine ("ldx #$00");
+                AddCodeLine ("lda %s", ED_GetLabelName (&Arg1.Expr, 0));
+            } else {
+                /* Drop part of the generated code so we have the first argument
+                ** in the primary
+                */
+                RemoveCode (&Arg1.Push);
 
-    } else if ((IS_Get (&CodeSizeFactor) >= 165) &&
-               ((ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr)) ||
-                (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr))) &&
-               ((ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) ||
-                (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr))) &&
-               (IS_Get (&InlineStdFuncs) || (ECount1 > 0 && ECount1 < 256))) {
+                /* Fetch the first char */
+                g_getind (CF_CHAR | CF_UNSIGNED, 0);
+            }
 
+        } else if ((IS_Get (&CodeSizeFactor) >= 165) &&
+                   ((ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr)) ||
+                    (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr))) &&
+                   ((ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) ||
+                    (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr))) &&
+                   (IS_Get (&EagerlyInlineFuncs) || (ECount1 > 0 && ECount1 < 256))) {
 
-        unsigned    Entry, Loop, Fin;   /* Labels */
-        const char* Load;
-        const char* Compare;
+            unsigned    Entry, Loop, Fin;   /* Labels */
+            const char* Load;
+            const char* Compare;
 
-        if (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr)) {
-            Load = "lda (%s),y";
-        } else {
-            Load = "lda %s,y";
-        }
-        if (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr)) {
-            Compare = "cmp (%s),y";
-        } else {
-            Compare = "cmp %s,y";
-        }
+            if (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr)) {
+                Load = "lda (%s),y";
+            } else {
+                Load = "lda %s,y";
+            }
+            if (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr)) {
+                Compare = "cmp (%s),y";
+            } else {
+                Compare = "cmp %s,y";
+            }
 
-        /* Drop the generated code */
-        RemoveCode (&Arg1.Expr.Start);
-
-        /* We need labels */
-        Entry = GetLocalLabel ();
-        Loop  = GetLocalLabel ();
-        Fin   = GetLocalLabel ();
-
-        /* Generate strcmp code */
-        AddCodeLine ("ldy #$00");
-        AddCodeLine ("beq %s", LocalLabelName (Entry));
-        g_defcodelabel (Loop);
-        AddCodeLine ("tax");
-        AddCodeLine ("beq %s", LocalLabelName (Fin));
-        AddCodeLine ("iny");
-        g_defcodelabel (Entry);
-        AddCodeLine (Load, ED_GetLabelName (&Arg1.Expr, 0));
-        AddCodeLine (Compare, ED_GetLabelName (&Arg2.Expr, 0));
-        AddCodeLine ("beq %s", LocalLabelName (Loop));
-        AddCodeLine ("ldx #$01");
-        AddCodeLine ("bcs %s", LocalLabelName (Fin));
-        AddCodeLine ("ldx #$FF");
-        g_defcodelabel (Fin);
-
-    } else if ((IS_Get (&CodeSizeFactor) > 190) &&
-               ((ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr)) ||
-                (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr))) &&
-               (IS_Get (&InlineStdFuncs) || (ECount1 > 0 && ECount1 < 256))) {
-
-
-        unsigned    Entry, Loop, Fin;   /* Labels */
-        const char* Compare;
-
-        if (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr)) {
-            Compare = "cmp (%s),y";
-        } else {
-            Compare = "cmp %s,y";
-        }
+            /* Drop the generated code */
+            RemoveCode (&Arg1.Expr.Start);
 
-        /* Drop the generated code */
-        RemoveCode (&Arg1.Push);
+            /* We need labels */
+            Entry = GetLocalLabel ();
+            Loop  = GetLocalLabel ();
+            Fin   = GetLocalLabel ();
+
+            /* Generate strcmp code */
+            AddCodeLine ("ldy #$00");
+            AddCodeLine ("beq %s", LocalLabelName (Entry));
+            g_defcodelabel (Loop);
+            AddCodeLine ("tax");
+            AddCodeLine ("beq %s", LocalLabelName (Fin));
+            AddCodeLine ("iny");
+            g_defcodelabel (Entry);
+            AddCodeLine (Load, ED_GetLabelName (&Arg1.Expr, 0));
+            AddCodeLine (Compare, ED_GetLabelName (&Arg2.Expr, 0));
+            AddCodeLine ("beq %s", LocalLabelName (Loop));
+            AddCodeLine ("ldx #$01");
+            AddCodeLine ("bcs %s", LocalLabelName (Fin));
+            AddCodeLine ("ldx #$FF");
+            g_defcodelabel (Fin);
+
+        } else if ((IS_Get (&CodeSizeFactor) > 190) &&
+                   ((ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr)) ||
+                    (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr))) &&
+                   (IS_Get (&EagerlyInlineFuncs) || (ECount1 > 0 && ECount1 < 256))) {
 
-        /* We need labels */
-        Entry = GetLocalLabel ();
-        Loop  = GetLocalLabel ();
-        Fin   = GetLocalLabel ();
-
-        /* Store Arg1 into ptr1 */
-        AddCodeLine ("sta ptr1");
-        AddCodeLine ("stx ptr1+1");
-
-        /* Generate strcmp code */
-        AddCodeLine ("ldy #$00");
-        AddCodeLine ("beq %s", LocalLabelName (Entry));
-        g_defcodelabel (Loop);
-        AddCodeLine ("tax");
-        AddCodeLine ("beq %s", LocalLabelName (Fin));
-        AddCodeLine ("iny");
-        g_defcodelabel (Entry);
-        AddCodeLine ("lda (ptr1),y");
-        AddCodeLine (Compare, ED_GetLabelName (&Arg2.Expr, 0));
-        AddCodeLine ("beq %s", LocalLabelName (Loop));
-        AddCodeLine ("ldx #$01");
-        AddCodeLine ("bcs %s", LocalLabelName (Fin));
-        AddCodeLine ("ldx #$FF");
-        g_defcodelabel (Fin);
+            unsigned    Entry, Loop, Fin;   /* Labels */
+            const char* Compare;
 
+            if (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr)) {
+                Compare = "cmp (%s),y";
+            } else {
+                Compare = "cmp %s,y";
+            }
+
+            /* Drop the generated code */
+            RemoveCode (&Arg1.Push);
+
+            /* We need labels */
+            Entry = GetLocalLabel ();
+            Loop  = GetLocalLabel ();
+            Fin   = GetLocalLabel ();
+
+            /* Store Arg1 into ptr1 */
+            AddCodeLine ("sta ptr1");
+            AddCodeLine ("stx ptr1+1");
+
+            /* Generate strcmp code */
+            AddCodeLine ("ldy #$00");
+            AddCodeLine ("beq %s", LocalLabelName (Entry));
+            g_defcodelabel (Loop);
+            AddCodeLine ("tax");
+            AddCodeLine ("beq %s", LocalLabelName (Fin));
+            AddCodeLine ("iny");
+            g_defcodelabel (Entry);
+            AddCodeLine ("lda (ptr1),y");
+            AddCodeLine (Compare, ED_GetLabelName (&Arg2.Expr, 0));
+            AddCodeLine ("beq %s", LocalLabelName (Loop));
+            AddCodeLine ("ldx #$01");
+            AddCodeLine ("bcs %s", LocalLabelName (Fin));
+            AddCodeLine ("ldx #$FF");
+            g_defcodelabel (Fin);
+        }
     }
 
     /* The function result is an rvalue in the primary register */
@@ -983,142 +1009,154 @@ static void StdFunc_strcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
     /* Get the element count of argument 1 if it is an array */
     ECount = ArrayElementCount (&Arg1);
 
-    /* We've generated the complete code for the function now and know the
-    ** types of all parameters. Check for situations where better code can
-    ** be generated. If such a situation is detected, throw away the
-    ** generated, and emit better code.
-    */
-    if (((ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr)) ||
-         (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr))) &&
-        ((ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) ||
-         (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr))) &&
-        (IS_Get (&InlineStdFuncs) ||
-        (ECount != UNSPECIFIED && ECount < 256))) {
-
-        const char* Load;
-        const char* Store;
-        if (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr)) {
-            Load = "lda (%s),y";
-        } else {
-            Load = "lda %s,y";
-        }
-        if (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr)) {
-            Store = "sta (%s),y";
-        } else {
-            Store = "sta %s,y";
-        }
+    if (IS_Get (&InlineStdFuncs)) {
 
-        /* Drop the generated code */
-        RemoveCode (&Arg1.Expr.Start);
+        /* We've generated the complete code for the function now and know the
+        ** types of all parameters. Check for situations where better code can
+        ** be generated. If such a situation is detected, throw away the
+        ** generated, and emit better code.
+        */
+        if (((ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr)) ||
+             (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr))) &&
+            ((ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) ||
+             (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr))) &&
+            (IS_Get (&EagerlyInlineFuncs) ||
+            (ECount != UNSPECIFIED && ECount < 256))) {
+
+            const char* Load;
+            const char* Store;
+            if (ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr)) {
+                Load = "lda (%s),y";
+            } else {
+                Load = "lda %s,y";
+            }
+            if (ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr)) {
+                Store = "sta (%s),y";
+            } else {
+                Store = "sta %s,y";
+            }
 
-        /* We need labels */
-        L1 = GetLocalLabel ();
+            /* Drop the generated code */
+            RemoveCode (&Arg1.Expr.Start);
 
-        /* Generate strcpy code */
-        AddCodeLine ("ldy #$FF");
-        g_defcodelabel (L1);
-        AddCodeLine ("iny");
-        AddCodeLine (Load, ED_GetLabelName (&Arg2.Expr, 0));
-        AddCodeLine (Store, ED_GetLabelName (&Arg1.Expr, 0));
-        AddCodeLine ("bne %s", LocalLabelName (L1));
+            /* We need labels */
+            L1 = GetLocalLabel ();
 
-        /* strcpy returns argument #1 */
-        *Expr = Arg1.Expr;
+            /* Generate strcpy code */
+            AddCodeLine ("ldy #$FF");
+            g_defcodelabel (L1);
+            AddCodeLine ("iny");
+            AddCodeLine (Load, ED_GetLabelName (&Arg2.Expr, 0));
+            AddCodeLine (Store, ED_GetLabelName (&Arg1.Expr, 0));
+            AddCodeLine ("bne %s", LocalLabelName (L1));
 
-    } else if (ED_IsRVal (&Arg2.Expr) && ED_IsLocStack (&Arg2.Expr) &&
-               StackPtr >= -255 &&
-               ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) {
+            /* strcpy returns argument #1 */
+            *Expr = Arg1.Expr;
 
-        /* It is possible to just use one index register even if the stack
-        ** offset is not zero, by adjusting the offset to the constant
-        ** address accordingly. But we cannot do this if the data in
-        ** question is in the register space or at an absolute address less
-        ** than 256. Register space is zero page, which means that the
-        ** address calculation could overflow in the linker.
-        */
-        int AllowOneIndex = !ED_IsLocRegister (&Arg1.Expr) &&
-                            !(ED_IsLocAbs (&Arg1.Expr) && Arg1.Expr.IVal < 256);
+            /* Bail out, no need for further processing */
+            goto ExitPoint;
+        }
 
-        /* Calculate the real stack offset */
-        int Offs = ED_GetStackOffs (&Arg2.Expr, 0);
+        if (ED_IsRVal (&Arg2.Expr) && ED_IsLocStack (&Arg2.Expr) &&
+            StackPtr >= -255 &&
+            ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) {
 
-        /* Drop the generated code */
-        RemoveCode (&Arg1.Expr.Start);
+            /* It is possible to just use one index register even if the stack
+            ** offset is not zero, by adjusting the offset to the constant
+            ** address accordingly. But we cannot do this if the data in
+            ** question is in the register space or at an absolute address less
+            ** than 256. Register space is zero page, which means that the
+            ** address calculation could overflow in the linker.
+            */
+            int AllowOneIndex = !ED_IsLocRegister (&Arg1.Expr) &&
+                                !(ED_IsLocAbs (&Arg1.Expr) && Arg1.Expr.IVal < 256);
 
-        /* We need labels */
-        L1 = GetLocalLabel ();
+            /* Calculate the real stack offset */
+            int Offs = ED_GetStackOffs (&Arg2.Expr, 0);
 
-        /* Generate strcpy code */
-        AddCodeLine ("ldy #$%02X", (unsigned char) (Offs - 1));
-        if (Offs == 0 || AllowOneIndex) {
-            g_defcodelabel (L1);
-            AddCodeLine ("iny");
-            AddCodeLine ("lda (sp),y");
-            AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, -Offs));
-        } else {
-            AddCodeLine ("ldx #$FF");
-            g_defcodelabel (L1);
-            AddCodeLine ("iny");
-            AddCodeLine ("inx");
-            AddCodeLine ("lda (sp),y");
-            AddCodeLine ("sta %s,x", ED_GetLabelName (&Arg1.Expr, 0));
-        }
-        AddCodeLine ("bne %s", LocalLabelName (L1));
+            /* Drop the generated code */
+            RemoveCode (&Arg1.Expr.Start);
 
-        /* strcpy returns argument #1 */
-        *Expr = Arg1.Expr;
+            /* We need labels */
+            L1 = GetLocalLabel ();
 
-    } else if (ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr) &&
-               ED_IsRVal (&Arg1.Expr) && ED_IsLocStack (&Arg1.Expr) &&
-               StackPtr >= -255) {
+            /* Generate strcpy code */
+            AddCodeLine ("ldy #$%02X", (unsigned char) (Offs - 1));
+            if (Offs == 0 || AllowOneIndex) {
+                g_defcodelabel (L1);
+                AddCodeLine ("iny");
+                AddCodeLine ("lda (sp),y");
+                AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, -Offs));
+            } else {
+                AddCodeLine ("ldx #$FF");
+                g_defcodelabel (L1);
+                AddCodeLine ("iny");
+                AddCodeLine ("inx");
+                AddCodeLine ("lda (sp),y");
+                AddCodeLine ("sta %s,x", ED_GetLabelName (&Arg1.Expr, 0));
+            }
+            AddCodeLine ("bne %s", LocalLabelName (L1));
 
-        /* It is possible to just use one index register even if the stack
-        ** offset is not zero, by adjusting the offset to the constant
-        ** address accordingly. But we cannot do this if the data in
-        ** question is in the register space or at an absolute address less
-        ** than 256. Register space is zero page, which means that the
-        ** address calculation could overflow in the linker.
-        */
-        int AllowOneIndex = !ED_IsLocRegister (&Arg2.Expr) &&
-                            !(ED_IsLocAbs (&Arg2.Expr) && Arg2.Expr.IVal < 256);
+            /* strcpy returns argument #1 */
+            *Expr = Arg1.Expr;
 
-        /* Calculate the real stack offset */
-        int Offs = ED_GetStackOffs (&Arg1.Expr, 0);
+            /* Bail out, no need for further processing */
+            goto ExitPoint;
+        }
 
-        /* Drop the generated code */
-        RemoveCode (&Arg1.Expr.Start);
+        if (ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr) &&
+            ED_IsRVal (&Arg1.Expr) && ED_IsLocStack (&Arg1.Expr) &&
+            StackPtr >= -255) {
 
-        /* We need labels */
-        L1 = GetLocalLabel ();
+            /* It is possible to just use one index register even if the stack
+            ** offset is not zero, by adjusting the offset to the constant
+            ** address accordingly. But we cannot do this if the data in
+            ** question is in the register space or at an absolute address less
+            ** than 256. Register space is zero page, which means that the
+            ** address calculation could overflow in the linker.
+            */
+            int AllowOneIndex = !ED_IsLocRegister (&Arg2.Expr) &&
+                                !(ED_IsLocAbs (&Arg2.Expr) && Arg2.Expr.IVal < 256);
 
-        /* Generate strcpy code */
-        AddCodeLine ("ldy #$%02X", (unsigned char) (Offs - 1));
-        if (Offs == 0 || AllowOneIndex) {
-            g_defcodelabel (L1);
-            AddCodeLine ("iny");
-            AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs));
-            AddCodeLine ("sta (sp),y");
-        } else {
-            AddCodeLine ("ldx #$FF");
-            g_defcodelabel (L1);
-            AddCodeLine ("iny");
-            AddCodeLine ("inx");
-            AddCodeLine ("lda %s,x", ED_GetLabelName (&Arg2.Expr, 0));
-            AddCodeLine ("sta (sp),y");
-        }
-        AddCodeLine ("bne %s", LocalLabelName (L1));
+            /* Calculate the real stack offset */
+            int Offs = ED_GetStackOffs (&Arg1.Expr, 0);
 
-        /* strcpy returns argument #1 */
-        *Expr = Arg1.Expr;
+            /* Drop the generated code */
+            RemoveCode (&Arg1.Expr.Start);
 
-    } else {
+            /* We need labels */
+            L1 = GetLocalLabel ();
+
+            /* Generate strcpy code */
+            AddCodeLine ("ldy #$%02X", (unsigned char) (Offs - 1));
+            if (Offs == 0 || AllowOneIndex) {
+                g_defcodelabel (L1);
+                AddCodeLine ("iny");
+                AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs));
+                AddCodeLine ("sta (sp),y");
+            } else {
+                AddCodeLine ("ldx #$FF");
+                g_defcodelabel (L1);
+                AddCodeLine ("iny");
+                AddCodeLine ("inx");
+                AddCodeLine ("lda %s,x", ED_GetLabelName (&Arg2.Expr, 0));
+                AddCodeLine ("sta (sp),y");
+            }
+            AddCodeLine ("bne %s", LocalLabelName (L1));
 
-        /* The function result is an rvalue in the primary register */
-        ED_MakeRValExpr (Expr);
-        Expr->Type = GetFuncReturn (Expr->Type);
+            /* strcpy returns argument #1 */
+            *Expr = Arg1.Expr;
 
+            /* Bail out, no need for further processing */
+            goto ExitPoint;
+        }
     }
 
+    /* The function result is an rvalue in the primary register */
+    ED_MakeRValExpr (Expr);
+    Expr->Type = GetFuncReturn (Expr->Type);
+
+ExitPoint:
     /* We expect the closing brace */
     ConsumeRParen ();
 }
@@ -1142,8 +1180,6 @@ static void StdFunc_strlen (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
     long        ECount;
     unsigned    L;
 
-
-
     /* Setup the argument type string */
     ArgType[1].C = GetDefaultChar () | T_QUAL_CONST;
 
@@ -1175,125 +1211,147 @@ static void StdFunc_strlen (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
     /* Do type conversion */
     TypeConversion (&Arg, ArgType);
 
-    /* If the expression is a literal, and if string literals are read
-    ** only, we can calculate the length of the string and remove it
-    ** from the literal pool. Otherwise we have to calculate the length
-    ** at runtime.
-    */
-    if (ED_IsLocLiteral (&Arg) && IS_Get (&WritableStrings) == 0) {
+    if (IS_Get (&Optimize)) {
 
-        /* Constant string literal */
-        ED_MakeConstAbs (Expr, GetLiteralSize (Arg.LVal) - 1, type_size_t);
+        /* If the expression is a literal, and if string literals are read
+        ** only, we can calculate the length of the string and remove it
+        ** from the literal pool. Otherwise we have to calculate the length
+        ** at runtime.
+        */
+        if (ED_IsLocLiteral (&Arg) && IS_Get (&WritableStrings) == 0) {
 
-        /* We don't need the literal any longer */
-        ReleaseLiteral (Arg.LVal);
+            /* Constant string literal */
+            ED_MakeConstAbs (Expr, GetLiteralSize (Arg.LVal) - 1, type_size_t);
 
-    /* We will inline strlen for arrays with constant addresses, if either the
-    ** inlining was forced on the command line, or the array is smaller than
-    ** 256, so the inlining is considered safe.
-    */
-    } else if (ED_IsLocConst (&Arg) && IsArray &&
-               (IS_Get (&InlineStdFuncs) || IsByteIndex)) {
-
-        /* Generate the strlen code */
-        L = GetLocalLabel ();
-        AddCodeLine ("ldy #$FF");
-        g_defcodelabel (L);
-        AddCodeLine ("iny");
-        AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg, 0));
-        AddCodeLine ("bne %s", LocalLabelName (L));
-        AddCodeLine ("tax");
-        AddCodeLine ("tya");
-
-        /* The function result is an rvalue in the primary register */
-        ED_MakeRValExpr (Expr);
-        Expr->Type = type_size_t;
-
-    /* We will inline strlen for arrays on the stack, if the array is
-    ** completely within the reach of a byte sized index register.
-    */
-    } else if (ED_IsLocStack (&Arg) && IsArray && IsByteIndex &&
-               (Arg.IVal - StackPtr) + ECount < 256) {
-
-        /* Calculate the true stack offset */
-        int Offs = ED_GetStackOffs (&Arg, 0);
-
-        /* Generate the strlen code */
-        L = GetLocalLabel ();
-        AddCodeLine ("ldx #$FF");
-        AddCodeLine ("ldy #$%02X", (unsigned char) (Offs-1));
-        g_defcodelabel (L);
-        AddCodeLine ("inx");
-        AddCodeLine ("iny");
-        AddCodeLine ("lda (sp),y");
-        AddCodeLine ("bne %s", LocalLabelName (L));
-        AddCodeLine ("txa");
-        AddCodeLine ("ldx #$00");
-
-        /* The function result is an rvalue in the primary register */
-        ED_MakeRValExpr (Expr);
-        Expr->Type = type_size_t;
-
-    /* strlen for a string that is pointed to by a register variable will only
-    ** get inlined if requested on the command line, since we cannot know how
-    ** big the buffer actually is, so inlining is not always safe.
-    */
-    } else if (ED_IsLocRegister (&Arg) && ED_IsLVal (&Arg) && IsPtr &&
-               IS_Get (&InlineStdFuncs)) {
-
-        /* Generate the strlen code */
-        L = GetLocalLabel ();
-        AddCodeLine ("ldy #$FF");
-        g_defcodelabel (L);
-        AddCodeLine ("iny");
-        AddCodeLine ("lda (%s),y", ED_GetLabelName (&Arg, 0));
-        AddCodeLine ("bne %s", LocalLabelName (L));
-        AddCodeLine ("tax");
-        AddCodeLine ("tya");
-
-        /* The function result is an rvalue in the primary register */
-        ED_MakeRValExpr (Expr);
-        Expr->Type = type_size_t;
-
-    /* Last check: We will inline a generic strlen routine if inlining was
-    ** requested on the command line, and the code size factor is more than
-    ** 400 (code is 13 bytes vs. 3 for a jsr call).
-    */
-    } else if (IS_Get (&CodeSizeFactor) > 400 && IS_Get (&InlineStdFuncs)) {
-
-        /* Load the expression into the primary */
-        LoadExpr (CF_NONE, &Arg);
-
-        /* Inline the function */
-        L = GetLocalLabel ();
-        AddCodeLine ("sta ptr1");
-        AddCodeLine ("stx ptr1+1");
-        AddCodeLine ("ldy #$FF");
-        g_defcodelabel (L);
-        AddCodeLine ("iny");
-        AddCodeLine ("lda (ptr1),y");
-        AddCodeLine ("bne %s", LocalLabelName (L));
-        AddCodeLine ("tax");
-        AddCodeLine ("tya");
-
-        /* The function result is an rvalue in the primary register */
-        ED_MakeRValExpr (Expr);
-        Expr->Type = type_size_t;
+            /* We don't need the literal any longer */
+            ReleaseLiteral (Arg.LVal);
 
-    } else {
+            /* Bail out, no need for further improvements */
+            goto ExitPoint;
+        }
+    }
+
+    if (IS_Get (&InlineStdFuncs)) {
+
+        /* We will inline strlen for arrays with constant addresses, if either
+        ** requested on the command line, or the array is smaller than 256,
+        ** so the inlining is considered safe.
+        */
+        if (ED_IsLocConst (&Arg) && IsArray &&
+            (IS_Get (&EagerlyInlineFuncs) || IsByteIndex)) {
+
+            /* Generate the strlen code */
+            L = GetLocalLabel ();
+            AddCodeLine ("ldy #$FF");
+            g_defcodelabel (L);
+            AddCodeLine ("iny");
+            AddCodeLine ("ldx %s,y", ED_GetLabelName (&Arg, 0));
+            AddCodeLine ("bne %s", LocalLabelName (L));
+            AddCodeLine ("tya");
+
+            /* The function result is an rvalue in the primary register */
+            ED_MakeRValExpr (Expr);
+            Expr->Type = type_size_t;
+
+            /* Bail out, no need for further processing */
+            goto ExitPoint;
+        }
+
+        /* We will inline strlen for arrays on the stack, if the array is
+        ** completely within the reach of a byte sized index register.
+        */
+        if (ED_IsLocStack (&Arg) && IsArray && IsByteIndex &&
+            (Arg.IVal - StackPtr) + ECount < 256) {
+
+            /* Calculate the true stack offset */
+            int Offs = ED_GetStackOffs (&Arg, 0);
+
+            /* Generate the strlen code */
+            L = GetLocalLabel ();
+            AddCodeLine ("ldx #$FF");
+            AddCodeLine ("ldy #$%02X", (unsigned char) (Offs-1));
+            g_defcodelabel (L);
+            AddCodeLine ("inx");
+            AddCodeLine ("iny");
+            AddCodeLine ("lda (sp),y");
+            AddCodeLine ("bne %s", LocalLabelName (L));
+            AddCodeLine ("txa");
+            AddCodeLine ("ldx #$00");
+
+            /* The function result is an rvalue in the primary register */
+            ED_MakeRValExpr (Expr);
+            Expr->Type = type_size_t;
+
+            /* Bail out, no need for further processing */
+            goto ExitPoint;
+        }
 
-        /* Load the expression into the primary */
-        LoadExpr (CF_NONE, &Arg);
+        /* strlen for a string that is pointed to by a register variable will only
+        ** get inlined if requested on the command line, since we cannot know how
+        ** big the buffer actually is, so inlining is not always safe.
+        */
+        if (ED_IsLocRegister (&Arg) && ED_IsLVal (&Arg) && IsPtr &&
+            IS_Get (&EagerlyInlineFuncs)) {
 
-        /* Call the strlen function */
-        AddCodeLine ("jsr _%s", Func_strlen);
+            /* Generate the strlen code */
+            L = GetLocalLabel ();
+            AddCodeLine ("ldy #$FF");
+            g_defcodelabel (L);
+            AddCodeLine ("iny");
+            AddCodeLine ("lda (%s),y", ED_GetLabelName (&Arg, 0));
+            AddCodeLine ("bne %s", LocalLabelName (L));
+            AddCodeLine ("tax");
+            AddCodeLine ("tya");
+
+            /* The function result is an rvalue in the primary register */
+            ED_MakeRValExpr (Expr);
+            Expr->Type = type_size_t;
+
+            /* Bail out, no need for further processing */
+            goto ExitPoint;
+        }
+
+        /* Last check: We will inline a generic strlen routine if inlining was
+        ** requested on the command line, and the code size factor is more than
+        ** 400 (code is 13 bytes vs. 3 for a jsr call).
+        */
+        if (IS_Get (&CodeSizeFactor) > 400 && IS_Get (&EagerlyInlineFuncs)) {
 
-        /* The function result is an rvalue in the primary register */
-        ED_MakeRValExpr (Expr);
-        Expr->Type = type_size_t;
+            /* Load the expression into the primary */
+            LoadExpr (CF_NONE, &Arg);
 
+            /* Inline the function */
+            L = GetLocalLabel ();
+            AddCodeLine ("sta ptr1");
+            AddCodeLine ("stx ptr1+1");
+            AddCodeLine ("ldy #$FF");
+            g_defcodelabel (L);
+            AddCodeLine ("iny");
+            AddCodeLine ("lda (ptr1),y");
+            AddCodeLine ("bne %s", LocalLabelName (L));
+            AddCodeLine ("tax");
+            AddCodeLine ("tya");
+
+            /* The function result is an rvalue in the primary register */
+            ED_MakeRValExpr (Expr);
+            Expr->Type = type_size_t;
+
+            /* Bail out, no need for further processing */
+            goto ExitPoint;
+        }
     }
 
+    /* Load the expression into the primary */
+    LoadExpr (CF_NONE, &Arg);
+
+    /* Call the strlen function */
+    AddCodeLine ("jsr _%s", Func_strlen);
+
+    /* The function result is an rvalue in the primary register */
+    ED_MakeRValExpr (Expr);
+    Expr->Type = type_size_t;
+
+ExitPoint:
     /* We expect the closing brace */
     ConsumeRParen ();
 }
index 84b516dc30180f92f85cd449bed8142bd5993e22..c6167fa78cb08d757a7a6cab5ee746144ee448c8 100644 (file)
@@ -273,9 +273,6 @@ static void WhileStatement (void)
     /* Remember the current position */
     GetCodePos (&CondCodeStart);
 
-    /* Emit the code position label */
-    g_defcodelabel (CondLabel);
-
     /* Test the loop condition */
     TestInParens (LoopLabel, 1);
 
@@ -288,6 +285,9 @@ static void WhileStatement (void)
     /* Loop body */
     Statement (&PendingToken);
 
+    /* Emit the while condition label */
+    g_defcodelabel (CondLabel);
+
     /* Move the test code here */
     GetCodePos (&Here);
     MoveCode (&CondCodeStart, &CondCodeEnd, &Here);
index 980ee27f2dab87e2c62fcf7f847a7ec5f12e842b..d6e68d1bbbdd291b51d175ba28a600add40acae9 100644 (file)
@@ -71,6 +71,7 @@ SymEntry* NewSymEntry (const char* Name, unsigned Flags)
     E->Type     = 0;
     E->Attr     = 0;
     E->AsmName  = 0;
+    E->V.BssName = 0;
     memcpy (E->Name, Name, Len+1);
 
     /* Return the new entry */
index 4fa84255b4b4d8d1e07349dba19c49dce4a9f403..ff136702f6cfd9849918988ed84aee204e6ec2d2 100644 (file)
@@ -153,6 +153,8 @@ struct SymEntry {
             struct LiteralPool* LitPool;  /* Literal pool for this function */
         } F;
 
+        /* Segment name for tentantive global definitions */
+        const char*             BssName;
     } V;
     char                       Name[1]; /* Name, dynamically allocated */
 };
index fdf45987370581f3d833104d92f937c4080b7d70..3275332c5490c68b89ab7a5c4b6e560716574144 100644 (file)
@@ -821,7 +821,7 @@ SymEntry* AddGlobalSym (const char* Name, const Type* T, unsigned Flags)
         }
 
         /* An extern declaration must not change the current linkage. */
-        if (IsFunc || (Flags & (SC_EXTERN | SC_DEF)) == SC_EXTERN) {
+        if (IsFunc || (Flags & (SC_EXTERN | SC_STORAGE)) == SC_EXTERN) {
             Flags &= ~SC_EXTERN;
         }
 
diff --git a/src/cc65/wrappedcall.c b/src/cc65/wrappedcall.c
new file mode 100644 (file)
index 0000000..2d11245
--- /dev/null
@@ -0,0 +1,102 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                                wrappedcall.c                              */
+/*                                                                           */
+/*                          WrappedCall management                           */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2017, Mega Cat Studios                                                */
+/*                                                                           */
+/*                                                                           */
+/* This software is provided 'as-is', without any expressed or implied       */
+/* warranty.  In no event will the authors be held liable for any damages    */
+/* arising from the use of this software.                                    */
+/*                                                                           */
+/* Permission is granted to anyone to use this software for any purpose,     */
+/* including commercial applications, and to alter it and redistribute it    */
+/* freely, subject to the following restrictions:                            */
+/*                                                                           */
+/* 1. The origin of this software must not be misrepresented; you must not   */
+/*    claim that you wrote the original software. If you use this software   */
+/*    in a product, an acknowledgment in the product documentation would be  */
+/*    appreciated but is not required.                                       */
+/* 2. Altered source versions must be plainly marked as such, and must not   */
+/*    be misrepresented as being the original software.                      */
+/* 3. This notice may not be removed or altered from any source              */
+/*    distribution.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+
+
+#include <stdarg.h>
+#include <string.h>
+
+/* common */
+#include "chartype.h"
+#include "check.h"
+#include "coll.h"
+#include "scanner.h"
+#include "intptrstack.h"
+#include "xmalloc.h"
+
+/* cc65 */
+#include "codeent.h"
+#include "error.h"
+#include "wrappedcall.h"
+
+
+
+/*****************************************************************************/
+/*                                   Data                                    */
+/*****************************************************************************/
+
+
+/* WrappedCalls */
+static IntPtrStack WrappedCalls;
+
+
+
+/*****************************************************************************/
+/*                                   Code                                    */
+/*****************************************************************************/
+
+
+
+void PushWrappedCall (void *Ptr, unsigned char Val)
+/* Push the current WrappedCall */
+{
+    if (IPS_IsFull (&WrappedCalls)) {
+        Error ("WrappedCall stack overflow");
+    } else {
+        IPS_Push (&WrappedCalls, Val, Ptr);
+    }
+}
+
+
+
+void PopWrappedCall (void)
+/* Remove the current WrappedCall */
+{
+    if (IPS_GetCount (&WrappedCalls) < 1) {
+        Error ("WrappedCall stack is empty");
+    } else {
+        IPS_Drop (&WrappedCalls);
+    }
+}
+
+
+
+void GetWrappedCall (void **Ptr, unsigned char *Val)
+/* Get the current WrappedCall */
+{
+    if (IPS_GetCount (&WrappedCalls) < 1) {
+        *Ptr = NULL;
+        *Val = 0;
+    } else {
+        long Temp;
+        IPS_Get (&WrappedCalls, &Temp, Ptr);
+        *Val = Temp;
+    }
+}
diff --git a/src/cc65/wrappedcall.h b/src/cc65/wrappedcall.h
new file mode 100644 (file)
index 0000000..3517c24
--- /dev/null
@@ -0,0 +1,65 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                                wrappedcall.h                              */
+/*                                                                           */
+/*                            Wrapped-call management                        */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2017, Mega Cat Studios                                                */
+/*                                                                           */
+/*                                                                           */
+/* This software is provided 'as-is', without any expressed or implied       */
+/* warranty.  In no event will the authors be held liable for any damages    */
+/* arising from the use of this software.                                    */
+/*                                                                           */
+/* Permission is granted to anyone to use this software for any purpose,     */
+/* including commercial applications, and to alter it and redistribute it    */
+/* freely, subject to the following restrictions:                            */
+/*                                                                           */
+/* 1. The origin of this software must not be misrepresented; you must not   */
+/*    claim that you wrote the original software. If you use this software   */
+/*    in a product, an acknowledgment in the product documentation would be  */
+/*    appreciated but is not required.                                       */
+/* 2. Altered source versions must be plainly marked as such, and must not   */
+/*    be misrepresented as being the original software.                      */
+/* 3. This notice may not be removed or altered from any source              */
+/*    distribution.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+
+
+#ifndef WRAPPEDCALL_H
+#define WRAPPEDCALL_H
+
+
+
+#include <stdio.h>
+
+/* common */
+#include "attrib.h"
+
+/* cc65 */
+#include "opcodes.h"
+
+
+/*****************************************************************************/
+/*                                   Code                                    */
+/*****************************************************************************/
+
+
+
+void PushWrappedCall (void *Ptr, unsigned char Val);
+/* Push the current WrappedCall */
+
+void PopWrappedCall (void);
+/* Pop the current WrappedCall */
+
+void GetWrappedCall (void **Ptr, unsigned char *Val);
+/* Get the current WrappedCall, if any */
+
+
+/* End of wrappedcall.h */
+
+#endif
index 7bdbe7a8a8971d00032f1d368766e7e45f298d5b..565f20b45126307b8e1f2600cdeeacaf534b9221 100644 (file)
@@ -158,6 +158,34 @@ static char* TargetLib  = 0;
 
 
 
+/*****************************************************************************/
+/*                        Credential functions                               */
+/*****************************************************************************/
+
+
+
+static void DisableAssembling (void)
+{
+    DoAssemble = 0;
+}
+
+
+
+static void DisableLinking (void)
+{
+    DoLink = 0;
+}
+
+
+
+static void DisableAssemblingAndLinking (void)
+{
+    DisableAssembling ();
+    DisableLinking ();
+}
+
+
+
 /*****************************************************************************/
 /*                        Command structure handling                         */
 /*****************************************************************************/
@@ -706,6 +734,7 @@ static void Usage (void)
             "  -C name\t\t\tUse linker config file\n"
             "  -Cl\t\t\t\tMake local variables static\n"
             "  -D sym[=defn]\t\t\tDefine a preprocessor symbol\n"
+            "  -E\t\t\t\tStop after the preprocessing stage\n"
             "  -I dir\t\t\tSet a compiler include directory path\n"
             "  -L path\t\t\tSpecify a library search path\n"
             "  -Ln name\t\t\tCreate a VICE label file\n"
@@ -723,6 +752,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"
@@ -786,6 +816,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 */
@@ -1261,6 +1299,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  },
@@ -1398,8 +1437,7 @@ int main (int argc, char* argv [])
 
                 case 'S':
                     /* Dont assemble and link the created files */
-                    DoAssemble = 0;
-                    DoLink     = 0;
+                    DisableAssemblingAndLinking ();
                     break;
 
                 case 'T':
@@ -1411,17 +1449,35 @@ 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':
-                    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 */
-                        OptCCArgs (Arg, GetArg (&I, 3));
-                    } else if (Arg[2] == 'l' && Arg[3] == '\0') {
-                        /* -Wl: Pass options to linker */
-                        OptLdArgs (Arg, GetArg (&I, 3));
+                    /* 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;
+                       }
                     } else {
                         /* Anything else: Suppress warnings (compiler) */
                         CmdAddArg2 (&CC65, "-W", GetArg (&I, 2));
@@ -1430,7 +1486,7 @@ int main (int argc, char* argv [])
 
                 case 'c':
                     /* Don't link the resulting files */
-                    DoLink = 0;
+                    DisableLinking ();
                     break;
 
                 case 'd':
index 87a6966b7f6b16676b7341f4704caf497c264e5f..bb815cd15931a8900388f59a906efbccc4b20bec 100644 (file)
@@ -52,7 +52,7 @@
 O65Model Model = O65_MODEL_NONE;
 
 /* Name table */
-static const char* NameTable[O65_MODEL_COUNT] = {
+static const char* const NameTable[O65_MODEL_COUNT] = {
     "none",    
     "os/a65",
     "lunix",
index 053d2398181a70e9be7ddb1145fbaa73647ca256..39fea35e5f48fd6907a4e07c2bbac6d9130edd6a 100644 (file)
@@ -38,6 +38,7 @@
     <ClInclude Include="common\hashtab.h" />
     <ClInclude Include="common\hlldbgsym.h" />
     <ClInclude Include="common\inline.h" />
+    <ClInclude Include="common\intptrstack.h" />
     <ClInclude Include="common\intstack.h" />
     <ClInclude Include="common\inttypes.h" />
     <ClInclude Include="common\libdefs.h" />
@@ -87,6 +88,7 @@
     <ClCompile Include="common\gentype.c" />
     <ClCompile Include="common\hashfunc.c" />
     <ClCompile Include="common\hashtab.c" />
+    <ClCompile Include="common\intptrstack.c" />
     <ClCompile Include="common\intstack.c" />
     <ClCompile Include="common\matchpat.c" />
     <ClCompile Include="common\mmodel.c" />
diff --git a/src/common/intptrstack.c b/src/common/intptrstack.c
new file mode 100644 (file)
index 0000000..de02c09
--- /dev/null
@@ -0,0 +1,90 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                                intptrstack.c                              */
+/*                                                                           */
+/*                  Integer+ptr stack used for program settings              */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2017, Mega Cat Studios                                                */
+/*                                                                           */
+/*                                                                           */
+/* This software is provided 'as-is', without any expressed or implied       */
+/* warranty.  In no event will the authors be held liable for any damages    */
+/* arising from the use of this software.                                    */
+/*                                                                           */
+/* Permission is granted to anyone to use this software for any purpose,     */
+/* including commercial applications, and to alter it and redistribute it    */
+/* freely, subject to the following restrictions:                            */
+/*                                                                           */
+/* 1. The origin of this software must not be misrepresented; you must not   */
+/*    claim that you wrote the original software. If you use this software   */
+/*    in a product, an acknowledgment in the product documentation would be  */
+/*    appreciated but is not required.                                       */
+/* 2. Altered source versions must be plainly marked as such, and must not   */
+/*    be misrepresented as being the original software.                      */
+/* 3. This notice may not be removed or altered from any source              */
+/*    distribution.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+
+
+/* common */
+#include "check.h"
+#include "intptrstack.h"
+
+
+
+/*****************************************************************************/
+/*                                   Code                                    */
+/*****************************************************************************/
+
+
+
+void IPS_Get (const IntPtrStack* S, long *Val, void **Ptr)
+/* Get the value on top of an int stack */
+{
+    PRECONDITION (S->Count > 0);
+    if (Val) *Val = S->Stack[S->Count-1].val;
+    if (Ptr) *Ptr = S->Stack[S->Count-1].ptr;
+}
+
+
+
+void IPS_Set (IntPtrStack* S, long Val, void *Ptr)
+/* Set the value on top of an int stack */
+{
+    PRECONDITION (S->Count > 0);
+    S->Stack[S->Count-1].val = Val;
+    S->Stack[S->Count-1].ptr = Ptr;
+}
+
+
+
+void IPS_Drop (IntPtrStack* S)
+/* Drop a value from an int stack */
+{
+    PRECONDITION (S->Count > 0);
+    --S->Count;
+}
+
+
+
+void IPS_Push (IntPtrStack* S, long Val, void *Ptr)
+/* Push a value onto an int stack */
+{
+    PRECONDITION (S->Count < sizeof (S->Stack) / sizeof (S->Stack[0]));
+    S->Stack[S->Count].val = Val;
+    S->Stack[S->Count++].ptr = Ptr;
+}
+
+
+
+void IPS_Pop (IntPtrStack* S, long *Val, void **Ptr)
+/* Pop a value from an int stack */
+{
+    PRECONDITION (S->Count > 0);
+    if (Val) *Val = S->Stack[--S->Count].val;
+    if (Ptr) *Ptr = S->Stack[S->Count].ptr;
+}
diff --git a/src/common/intptrstack.h b/src/common/intptrstack.h
new file mode 100644 (file)
index 0000000..a7b1c66
--- /dev/null
@@ -0,0 +1,121 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                                intptrstack.h                              */
+/*                                                                           */
+/*                  Integer+ptr stack used for program settings              */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2017, Mega Cat Studios                                                */
+/*                                                                           */
+/*                                                                           */
+/* This software is provided 'as-is', without any expressed or implied       */
+/* warranty.  In no event will the authors be held liable for any damages    */
+/* arising from the use of this software.                                    */
+/*                                                                           */
+/* Permission is granted to anyone to use this software for any purpose,     */
+/* including commercial applications, and to alter it and redistribute it    */
+/* freely, subject to the following restrictions:                            */
+/*                                                                           */
+/* 1. The origin of this software must not be misrepresented; you must not   */
+/*    claim that you wrote the original software. If you use this software   */
+/*    in a product, an acknowledgment in the product documentation would be  */
+/*    appreciated but is not required.                                       */
+/* 2. Altered source versions must be plainly marked as such, and must not   */
+/*    be misrepresented as being the original software.                      */
+/* 3. This notice may not be removed or altered from any source              */
+/*    distribution.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+
+
+#ifndef INTPTRSTACK_H
+#define INTPTRSTACK_H
+
+
+
+#include "inline.h"
+
+
+
+/*****************************************************************************/
+/*                                   Data                                    */
+/*****************************************************************************/
+
+
+
+typedef struct IntPtrStack IntPtrStack;
+struct IntPtrInner {
+       long val;
+       void *ptr;
+};
+struct IntPtrStack {
+    unsigned    Count;
+    struct IntPtrInner Stack[8];
+};
+
+/* An initializer for an empty int stack */
+#define STATIC_INTPTRSTACK_INITIALIZER     { 0, { 0, 0 }, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} } }
+
+/* Declare an int stack with the given value as first element */
+#define INTPTRSTACK(Val, Ptr)   { 1, { {Val, Ptr}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} } }
+
+
+
+/*****************************************************************************/
+/*                                   Code                                    */
+/*****************************************************************************/
+
+
+
+#if defined(HAVE_INLINE)
+INLINE int IPS_IsFull (const IntPtrStack* S)
+/* Return true if there is no space left on the given int stack */
+{
+    return (S->Count >= sizeof (S->Stack) / sizeof (S->Stack[0]));
+}
+#else
+#  define IPS_IsFull(S)  ((S)->Count >= sizeof ((S)->Stack) / sizeof ((S)->Stack[0]))
+#endif
+
+#if defined(HAVE_INLINE)
+INLINE int IPS_IsEmpty (const IntPtrStack* S)
+/* Return true if there are no values on the given int stack */
+{
+    return (S->Count == 0);
+}
+#else
+#  define IPS_IsEmpty(S)  ((S)->Count == 0)
+#endif
+
+#if defined(HAVE_INLINE)
+INLINE unsigned IPS_GetCount (const IntPtrStack* S)
+/* Return the number of elements on the given int stack */
+{
+    return S->Count;
+}
+#else
+#  define IPS_GetCount(S)        (S)->Count
+#endif
+
+void IPS_Get (const IntPtrStack* S, long *Val, void **Ptr);
+/* Get the value on top of an int stack */
+
+void IPS_Set (IntPtrStack* S, long Val, void *Ptr);
+/* Set the value on top of an int stack */
+
+void IPS_Drop (IntPtrStack* S);
+/* Drop a value from an int stack */
+
+void IPS_Push (IntPtrStack* S, long Val, void *Ptr);
+/* Push a value onto an int stack */
+
+void IPS_Pop (IntPtrStack* S, long *Val, void **Ptr);
+/* Pop a value from an int stack */
+
+
+
+/* End of IntPtrStack.h */
+
+#endif
index 4e61a5f8388b5d9704fdc331c0a5f5af2464b57a..bf0a6bf7163bd4ca9ca9d6a1f1c71a7734080abf 100644 (file)
@@ -47,7 +47,7 @@
 
 
 #define VER_MAJOR       2U
-#define VER_MINOR       15U
+#define VER_MINOR       16U
 
 
 
index 547a7986939ed94ec75f9ac3c16d773d0fdd4925..6aa7f38cfe2623595993e4e12114125db3bbd74d 100644 (file)
@@ -264,11 +264,11 @@ const char* GetLabel (unsigned Addr, unsigned RefFrom)
 ** of unnamed labels, to determine the name.
 */
 {
-    static const char* FwdLabels[] = {
+    static const char* const FwdLabels[] = {
         ":+", ":++", ":+++", ":++++", ":+++++", ":++++++", ":+++++++",
         ":++++++++", ":+++++++++", ":++++++++++"
     };
-    static const char* BackLabels[] = {
+    static const char* const BackLabels[] = {
         ":-", ":--", ":---", ":----", ":-----", ":------", ":-------",
         ":--------", ":---------", ":----------"
     };
index 2a1fef95372321b4bf93e8180ade9445907461a2..a53801a395028eb3bafd4926b5d068bc622185e6 100644 (file)
@@ -226,18 +226,18 @@ static void openSFile (void)
 }
 
 
-static int findToken (const char **tokenTbl, const char *token)
+static int findToken (const char * const *tokenTbl, const char *token)
 {
     /* takes as input table of tokens and token, returns position in table or -1 if not found */
-    int a = 0;
+    int i;
 
-    while (strlen (tokenTbl[a]) != 0) {
-        if (strcmp (tokenTbl[a], token) == 0) break;
-        a++;
+    for (i = 0; tokenTbl[i][0]; i++) {
+        if (strcmp (tokenTbl[i], token) == 0) {
+            return i;
+        }
     }
 
-    if (strlen (tokenTbl[a]) == 0) a = -1;
-    return a;
+    return -1;
 }
 
 
index e6f35829527a06f2d4aebd1c5bae2f1bb445e3ab..1febef6573b0510cf20a90b95eb8a2ae30084324 100644 (file)
@@ -11,6 +11,7 @@
 /*                D-70794 Filderstadt                                        */
 /* EMail:         uz@cc65.org                                                */
 /*                                                                           */
+/* Mar-2017, Christian Krueger, added support for 65SC02                     */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
 /* warranty.  In no event will the authors be held liable for any damages    */
 /*                                                                           */
 /*****************************************************************************/
 
-
+/* Known bugs and limitations of the 65C02 simulation:
+ * support currently only on the level of 65SC02:
+   BBRx, BBSx, RMBx, SMBx, WAI, and STP are unsupported
+ * BCD flag handling equals 6502 (unchecked if bug is simulated or wrong for
+   6502)
+ * one cycle win for fetch-modify-write instructions ignored
+   (e.g., ROL abs,x takes only 6 cycles if no page break occurs)
+*/
 
 #include "memory.h"
 #include "error.h"
@@ -77,12 +85,11 @@ int PrintCycles;
 
 
 
-/* Return the flags as a boolean value (0/1) */
+/* Return the flags as boolean values (0/1) */
 #define GET_CF()        ((Regs.SR & CF) != 0)
 #define GET_ZF()        ((Regs.SR & ZF) != 0)
 #define GET_IF()        ((Regs.SR & IF) != 0)
 #define GET_DF()        ((Regs.SR & DF) != 0)
-#define GET_BF()        ((Regs.SR & BF) != 0)
 #define GET_OF()        ((Regs.SR & OF) != 0)
 #define GET_SF()        ((Regs.SR & SF) != 0)
 
@@ -93,7 +100,6 @@ int PrintCycles;
 #define SET_ZF(f)       do { if (f) { Regs.SR |= ZF; } else { Regs.SR &= ~ZF; } } while (0)
 #define SET_IF(f)       do { if (f) { Regs.SR |= IF; } else { Regs.SR &= ~IF; } } while (0)
 #define SET_DF(f)       do { if (f) { Regs.SR |= DF; } else { Regs.SR &= ~DF; } } while (0)
-#define SET_BF(f)       do { if (f) { Regs.SR |= BF; } else { Regs.SR &= ~BF; } } while (0)
 #define SET_OF(f)       do { if (f) { Regs.SR |= OF; } else { Regs.SR &= ~OF; } } while (0)
 #define SET_SF(f)       do { if (f) { Regs.SR |= SF; } else { Regs.SR &= ~SF; } } while (0)
 
@@ -109,8 +115,8 @@ int PrintCycles;
 #define PCH             ((Regs.PC >> 8) & 0xFF)
 
 /* Stack operations */
-#define PUSH(Val)       MemWriteByte (0x0100 + Regs.SP--, Val)
-#define POP()           MemReadByte (0x0100 + ++Regs.SP)
+#define PUSH(Val)       MemWriteByte (0x0100 | (Regs.SP-- & 0xFF), Val)
+#define POP()           MemReadByte (0x0100 | (++Regs.SP & 0xFF))
 
 /* Test for page cross */
 #define PAGE_CROSS(addr,offs)   ((((addr) & 0xFF) + offs) >= 0x100)
@@ -205,7 +211,23 @@ int PrintCycles;
     unsigned Addr;                                              \
     Cycles = 5;                                                 \
     ZPAddr = MemReadByte (Regs.PC+1);                           \
-    Addr = MemReadZPWord (ZPAddr) + Regs.YR;                    \
+    Addr = MemReadZPWord (ZPAddr);                              \
+    if (PAGE_CROSS (Addr, Regs.YR)) {                           \
+        ++Cycles;                                               \
+    }                                                           \
+    Addr += Regs.YR;                                            \
+    Regs.AC = Regs.AC op MemReadByte (Addr);                    \
+    TEST_ZF (Regs.AC);                                          \
+    TEST_SF (Regs.AC);                                          \
+    Regs.PC += 2
+
+/* (zp) */
+#define AC_OP_ZPIND(op)                                         \
+    unsigned char ZPAddr;                                       \
+    unsigned Addr;                                              \
+    Cycles = 5;                                                 \
+    ZPAddr = MemReadByte (Regs.PC+1);                           \
+    Addr = MemReadZPWord (ZPAddr);                              \
     Regs.AC = Regs.AC op MemReadByte (Addr);                    \
     TEST_ZF (Regs.AC);                                          \
     TEST_SF (Regs.AC);                                          \
@@ -234,6 +256,9 @@ int PrintCycles;
             }                                                   \
             TEST_CF (Regs.AC);                                  \
             SET_OF ((res < -128) || (res > 127));               \
+            if (CPU != CPU_6502) {                              \
+                ++Cycles;                                       \
+            }                                                   \
         } else {                                                \
             Regs.AC += rhs + GET_CF ();                         \
             TEST_ZF (Regs.AC);                                  \
@@ -313,6 +338,9 @@ int PrintCycles;
             TEST_SF (res);                                      \
             SET_CF (res <= 0xFF);                               \
             SET_OF (((old^rhs) & (old^res) & 0x80));            \
+            if (CPU != CPU_6502) {                              \
+                ++Cycles;                                       \
+            }                                                   \
         } else {                                                \
             Regs.AC -= rhs + (!GET_CF ());                      \
             TEST_ZF (Regs.AC);                                  \
@@ -344,11 +372,14 @@ static void OPC_6502_00 (void)
 {
     Cycles = 7;
     Regs.PC += 2;
-    SET_BF (1);
     PUSH (PCH);
     PUSH (PCL);
     PUSH (Regs.SR);
     SET_IF (1);
+    if (CPU != CPU_6502)
+    {
+        SET_DF (0);
+    }
     Regs.PC = MemReadWord (0xFFFE);
 }
 
@@ -362,6 +393,21 @@ static void OPC_6502_01 (void)
 
 
 
+static void OPC_65SC02_04 (void)
+/* Opcode $04: TSB zp */
+{
+    unsigned char ZPAddr;
+    unsigned char Val;
+    Cycles = 5;
+    ZPAddr = MemReadByte (Regs.PC+1);
+    Val = MemReadByte (ZPAddr);
+    SET_ZF ((Val & Regs.AC) == 0);
+    MemWriteByte (ZPAddr, (unsigned char)(Val | Regs.AC));
+    Regs.PC += 2;
+}
+
+
+
 static void OPC_6502_05 (void)
 /* Opcode $05: ORA zp */
 {
@@ -377,7 +423,7 @@ static void OPC_6502_06 (void)
     unsigned Val;
     Cycles = 5;
     ZPAddr = MemReadByte (Regs.PC+1);
-    Val    = MemReadByte (ZPAddr) << 1;
+    Val = MemReadByte (ZPAddr) << 1;
     MemWriteByte (ZPAddr, (unsigned char) Val);
     TEST_ZF (Val & 0xFF);
     TEST_SF (Val);
@@ -391,7 +437,7 @@ static void OPC_6502_08 (void)
 /* Opcode $08: PHP */
 {
     Cycles = 3;
-    PUSH (Regs.SR & ~BF);
+    PUSH (Regs.SR);
     Regs.PC += 1;
 }
 
@@ -419,6 +465,21 @@ static void OPC_6502_0A (void)
 
 
 
+static void OPC_65SC02_0C (void)
+/* Opcode $0C: TSB abs */
+{
+    unsigned Addr;
+    unsigned char Val;
+    Cycles = 6;
+    Addr = MemReadWord (Regs.PC+1);
+    Val = MemReadByte (Addr);
+    SET_ZF ((Val & Regs.AC) == 0);
+    MemWriteByte (Addr, (unsigned char) (Val | Regs.AC));
+    Regs.PC += 3;
+}
+
+
+
 static void OPC_6502_0D (void)
 /* Opcode $0D: ORA abs */
 {
@@ -434,7 +495,7 @@ static void OPC_6502_0E (void)
     unsigned Val;
     Cycles = 6;
     Addr = MemReadWord (Regs.PC+1);
-    Val  = MemReadByte (Addr) << 1;
+    Val = MemReadByte (Addr) << 1;
     MemWriteByte (Addr, (unsigned char) Val);
     TEST_ZF (Val & 0xFF);
     TEST_SF (Val);
@@ -460,6 +521,29 @@ static void OPC_6502_11 (void)
 
 
 
+static void OPC_65SC02_12 (void)
+/* Opcode $12: ORA (zp) */
+{
+    AC_OP_ZPIND (|);
+}
+
+
+
+static void OPC_65SC02_14 (void)
+/* Opcode $14: TRB zp */
+{
+    unsigned char ZPAddr;
+    unsigned char Val;
+    Cycles = 5;
+    ZPAddr = MemReadByte (Regs.PC+1);
+    Val = MemReadByte (ZPAddr);
+    SET_ZF ((Val & Regs.AC) == 0);
+    MemWriteByte (ZPAddr, (unsigned char)(Val & ~Regs.AC));
+    Regs.PC += 2;
+}
+
+
+
 static void OPC_6502_15 (void)
 /* Opcode $15: ORA zp,x */
 {
@@ -475,7 +559,7 @@ static void OPC_6502_16 (void)
     unsigned Val;
     Cycles = 6;
     ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
-    Val    = MemReadByte (ZPAddr) << 1;
+    Val = MemReadByte (ZPAddr) << 1;
     MemWriteByte (ZPAddr, (unsigned char) Val);
     TEST_ZF (Val & 0xFF);
     TEST_SF (Val);
@@ -503,6 +587,33 @@ static void OPC_6502_19 (void)
 
 
 
+static void OPC_65SC02_1A (void)
+/* Opcode $1A: INC a */
+{
+    Cycles = 2;
+    Regs.AC = (Regs.AC + 1) & 0xFF;
+    TEST_ZF (Regs.AC);
+    TEST_SF (Regs.AC);
+    Regs.PC += 1;
+}
+
+
+
+static void OPC_65SC02_1C (void)
+/* Opcode $1C: TRB abs */
+{
+    unsigned Addr;
+    unsigned char Val;
+    Cycles = 6;
+    Addr = MemReadWord (Regs.PC+1);
+    Val = MemReadByte (Addr);
+    SET_ZF ((Val & Regs.AC) == 0);
+    MemWriteByte (Addr, (unsigned char) (Val & ~Regs.AC));
+    Regs.PC += 3;
+}
+
+
+
 static void OPC_6502_1D (void)
 /* Opcode $1D: ORA abs,x */
 {
@@ -518,7 +629,7 @@ static void OPC_6502_1E (void)
     unsigned Val;
     Cycles = 7;
     Addr = MemReadWord (Regs.PC+1) + Regs.XR;
-    Val  = MemReadByte (Addr) << 1;
+    Val = MemReadByte (Addr) << 1;
     MemWriteByte (Addr, (unsigned char) Val);
     TEST_ZF (Val & 0xFF);
     TEST_SF (Val);
@@ -533,7 +644,7 @@ static void OPC_6502_20 (void)
 {
     unsigned Addr;
     Cycles = 6;
-    Addr   = MemReadWord (Regs.PC+1);
+    Addr = MemReadWord (Regs.PC+1);
     Regs.PC += 2;
     PUSH (PCH);
     PUSH (PCL);
@@ -559,7 +670,7 @@ static void OPC_6502_24 (void)
     unsigned char Val;
     Cycles = 3;
     ZPAddr = MemReadByte (Regs.PC+1);
-    Val    = MemReadByte (ZPAddr);
+    Val = MemReadByte (ZPAddr);
     SET_SF (Val & 0x80);
     SET_OF (Val & 0x40);
     SET_ZF ((Val & Regs.AC) == 0);
@@ -583,7 +694,7 @@ static void OPC_6502_26 (void)
     unsigned Val;
     Cycles = 5;
     ZPAddr = MemReadByte (Regs.PC+1);
-    Val    = MemReadByte (ZPAddr);
+    Val = MemReadByte (ZPAddr);
     ROL (Val);
     MemWriteByte (ZPAddr, Val);
     Regs.PC += 2;
@@ -595,7 +706,9 @@ static void OPC_6502_28 (void)
 /* Opcode $28: PLP */
 {
     Cycles = 4;
-    Regs.SR = (POP () & ~BF);
+
+    /* Bits 5 and 4 aren't used, and always are 1! */
+    Regs.SR = (POP () | 0x30);
     Regs.PC += 1;
 }
 
@@ -627,7 +740,7 @@ static void OPC_6502_2C (void)
     unsigned char Val;
     Cycles = 4;
     Addr = MemReadByte (Regs.PC+1);
-    Val  = MemReadByte (Addr);
+    Val = MemReadByte (Addr);
     SET_SF (Val & 0x80);
     SET_OF (Val & 0x40);
     SET_ZF ((Val & Regs.AC) == 0);
@@ -651,7 +764,7 @@ static void OPC_6502_2E (void)
     unsigned Val;
     Cycles = 6;
     Addr = MemReadWord (Regs.PC+1);
-    Val  = MemReadByte (Addr);
+    Val = MemReadByte (Addr);
     ROL (Val);
     MemWriteByte (Addr, Val);
     Regs.PC += 3;
@@ -675,6 +788,30 @@ static void OPC_6502_31 (void)
 
 
 
+static void OPC_65SC02_32 (void)
+/* Opcode $32: AND (zp) */
+{
+    AC_OP_ZPIND (&);
+}
+
+
+
+static void OPC_65SC02_34 (void)
+/* Opcode $34: BIT zp,x */
+{
+    unsigned char ZPAddr;
+    unsigned char Val;
+    Cycles = 4;
+    ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
+    Val = MemReadByte (ZPAddr);
+    SET_SF (Val & 0x80);
+    SET_OF (Val & 0x40);
+    SET_ZF ((Val & Regs.AC) == 0);
+    Regs.PC += 2;
+}
+
+
+
 static void OPC_6502_35 (void)
 /* Opcode $35: AND zp,x */
 {
@@ -690,7 +827,7 @@ static void OPC_6502_36 (void)
     unsigned Val;
     Cycles = 6;
     ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
-    Val    = MemReadByte (ZPAddr);
+    Val = MemReadByte (ZPAddr);
     ROL (Val);
     MemWriteByte (ZPAddr, Val);
     Regs.PC += 2;
@@ -716,6 +853,36 @@ static void OPC_6502_39 (void)
 
 
 
+static void OPC_65SC02_3A (void)
+/* Opcode $3A: DEC a */
+{
+    Cycles = 2;
+    Regs.AC = (Regs.AC - 1) & 0xFF;
+    TEST_ZF (Regs.AC);
+    TEST_SF (Regs.AC);
+    Regs.PC += 1;
+}
+
+
+
+static void OPC_65SC02_3C (void)
+/* Opcode $3C: BIT abs,x */
+{
+    unsigned Addr;
+    unsigned char Val;
+    Cycles = 4;
+    Addr = MemReadWord (Regs.PC+1);
+    if (PAGE_CROSS (Addr, Regs.XR))
+        ++Cycles;
+    Val  = MemReadByte (Addr + Regs.XR);
+    SET_SF (Val & 0x80);
+    SET_OF (Val & 0x40);
+    SET_ZF ((Val & Regs.AC) == 0);
+    Regs.PC += 3;
+}
+
+
+
 static void OPC_6502_3D (void)
 /* Opcode $3D: AND abs,x */
 {
@@ -731,7 +898,7 @@ static void OPC_6502_3E (void)
     unsigned Val;
     Cycles = 7;
     Addr = MemReadWord (Regs.PC+1) + Regs.XR;
-    Val  = MemReadByte (Addr);
+    Val = MemReadByte (Addr);
     ROL (Val);
     MemWriteByte (Addr, Val);
     Regs.PC += 2;
@@ -743,7 +910,9 @@ static void OPC_6502_40 (void)
 /* Opcode $40: RTI */
 {
     Cycles = 6;
-    Regs.SR = POP ();
+
+    /* Bits 5 and 4 aren't used, and always are 1! */
+    Regs.SR = POP () | 0x30;
     Regs.PC = POP ();                /* PCL */
     Regs.PC |= (POP () << 8);        /* PCH */
 }
@@ -758,6 +927,15 @@ static void OPC_6502_41 (void)
 
 
 
+static void OPC_65C02_44 (void)
+/* Opcode $44: 'zp' 3 cycle NOP */
+{
+    Cycles = 3;
+    Regs.PC += 2;
+}
+
+
+
 static void OPC_6502_45 (void)
 /* Opcode $45: EOR zp */
 {
@@ -773,7 +951,7 @@ static void OPC_6502_46 (void)
     unsigned char Val;
     Cycles = 5;
     ZPAddr = MemReadByte (Regs.PC+1);
-    Val    = MemReadByte (ZPAddr);
+    Val = MemReadByte (ZPAddr);
     SET_CF (Val & 0x01);
     Val >>= 1;
     MemWriteByte (ZPAddr, Val);
@@ -841,7 +1019,7 @@ static void OPC_6502_4E (void)
     unsigned char Val;
     Cycles = 6;
     Addr = MemReadWord (Regs.PC+1);
-    Val  = MemReadByte (Addr);
+    Val = MemReadByte (Addr);
     SET_CF (Val & 0x01);
     Val >>= 1;
     MemWriteByte (Addr, Val);
@@ -868,6 +1046,14 @@ static void OPC_6502_51 (void)
 
 
 
+static void OPC_65SC02_52 (void)
+/* Opcode $52: EOR (zp) */
+{
+    AC_OP_ZPIND (^);
+}
+
+
+
 static void OPC_6502_55 (void)
 /* Opcode $55: EOR zp,x */
 {
@@ -883,7 +1069,7 @@ static void OPC_6502_56 (void)
     unsigned char Val;
     Cycles = 6;
     ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
-    Val    = MemReadByte (ZPAddr);
+    Val = MemReadByte (ZPAddr);
     SET_CF (Val & 0x01);
     Val >>= 1;
     MemWriteByte (ZPAddr, Val);
@@ -912,6 +1098,25 @@ static void OPC_6502_59 (void)
 
 
 
+static void OPC_65SC02_5A (void)
+/* Opcode $5A: PHY */
+{
+    Cycles = 3;
+    PUSH (Regs.YR);
+    Regs.PC += 1;
+}
+
+
+
+static void OPC_65C02_5C (void)
+/* Opcode $5C: 'Absolute' 8 cycle NOP */
+{
+    Cycles = 8;
+    Regs.PC += 3;
+}
+
+
+
 static void OPC_6502_5D (void)
 /* Opcode $5D: EOR abs,x */
 {
@@ -927,7 +1132,7 @@ static void OPC_6502_5E (void)
     unsigned char Val;
     Cycles = 7;
     Addr = MemReadWord (Regs.PC+1) + Regs.XR;
-    Val  = MemReadByte (Addr);
+    Val = MemReadByte (Addr);
     SET_CF (Val & 0x01);
     Val >>= 1;
     MemWriteByte (Addr, Val);
@@ -956,13 +1161,25 @@ static void OPC_6502_61 (void)
     unsigned Addr;
     Cycles = 6;
     ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
-    Addr   = MemReadZPWord (ZPAddr);
+    Addr = MemReadZPWord (ZPAddr);
     ADC (MemReadByte (Addr));
     Regs.PC += 2;
 }
 
 
 
+static void OPC_65SC02_64 (void)
+/* Opcode $64: STZ zp */
+{
+    unsigned char ZPAddr;
+    Cycles = 3;
+    ZPAddr = MemReadByte (Regs.PC+1);
+    MemWriteByte (ZPAddr, 0);
+    Regs.PC += 2;
+}
+
+
+
 static void OPC_6502_65 (void)
 /* Opcode $65: ADC zp */
 {
@@ -982,7 +1199,7 @@ static void OPC_6502_66 (void)
     unsigned Val;
     Cycles = 5;
     ZPAddr = MemReadByte (Regs.PC+1);
-    Val    = MemReadByte (ZPAddr);
+    Val = MemReadByte (ZPAddr);
     ROR (Val);
     MemWriteByte (ZPAddr, Val);
     Regs.PC += 2;
@@ -1026,19 +1243,28 @@ static void OPC_6502_6C (void)
 /* Opcode $6C: JMP (ind) */
 {
     unsigned PC, Lo, Hi;
-    Cycles = 5;
     PC = Regs.PC;
     Lo = MemReadWord (PC+1);
 
-    /* Emulate the 6502 bug */
-    Regs.PC = MemReadByte (Lo);
-    Hi = (Lo & 0xFF00) | ((Lo + 1) & 0xFF);
-    Regs.PC |= (MemReadByte (Hi) << 8);
-
-    /* Output a warning if the bug is triggered */
-    if (Hi != Lo + 1) {
-        Warning ("6502 indirect jump bug triggered at $%04X, ind addr = $%04X",
-                 PC, Lo);
+    if (CPU == CPU_6502)
+    {
+         /* Emulate the 6502 bug */
+        Cycles = 5;
+        Regs.PC = MemReadByte (Lo);
+        Hi = (Lo & 0xFF00) | ((Lo + 1) & 0xFF);
+        Regs.PC |= (MemReadByte (Hi) << 8);
+
+        /* Output a warning if the bug is triggered */
+        if (Hi != Lo + 1)
+        {
+            Warning ("6502 indirect jump bug triggered at $%04X, ind addr = $%04X",
+                     PC, Lo);
+        }
+    }
+    else
+    {
+        Cycles = 6;
+        Regs.PC = MemReadWord(Lo);
     }
 }
 
@@ -1106,6 +1332,32 @@ static void OPC_6502_71 (void)
 
 
 
+static void OPC_65SC02_72 (void)
+/* Opcode $72: ADC (zp) */
+{
+    unsigned char ZPAddr;
+    unsigned Addr;
+    Cycles = 5;
+    ZPAddr = MemReadByte (Regs.PC+1);
+    Addr   = MemReadZPWord (ZPAddr);
+    ADC (MemReadByte (Addr));
+    Regs.PC += 2;
+}
+
+
+
+static void OPC_65SC02_74 (void)
+/* Opcode $74: STZ zp,x */
+{
+    unsigned char ZPAddr;
+    Cycles = 4;
+    ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
+    MemWriteByte (ZPAddr, 0);
+    Regs.PC += 2;
+}
+
+
+
 static void OPC_6502_75 (void)
 /* Opcode $75: ADC zp,x */
 {
@@ -1125,7 +1377,7 @@ static void OPC_6502_76 (void)
     unsigned Val;
     Cycles = 6;
     ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
-    Val    = MemReadByte (ZPAddr);
+    Val = MemReadByte (ZPAddr);
     ROR (Val);
     MemWriteByte (ZPAddr, Val);
     Regs.PC += 2;
@@ -1148,7 +1400,7 @@ static void OPC_6502_79 (void)
 {
     unsigned Addr;
     Cycles = 4;
-    Addr   = MemReadWord (Regs.PC+1);
+    Addr = MemReadWord (Regs.PC+1);
     if (PAGE_CROSS (Addr, Regs.YR)) {
         ++Cycles;
     }
@@ -1158,12 +1410,36 @@ static void OPC_6502_79 (void)
 
 
 
+static void OPC_65SC02_7A (void)
+/* Opcode $7A: PLY */
+{
+    Cycles = 4;
+    Regs.YR = POP ();
+    TEST_ZF (Regs.YR);
+    TEST_SF (Regs.YR);
+    Regs.PC += 1;
+}
+
+
+
+static void OPC_65SC02_7C (void)
+/* Opcode $7C: JMP (ind,X) */
+{
+    unsigned PC, Adr;
+    Cycles = 6;
+    PC = Regs.PC;
+    Adr = MemReadWord (PC+1);
+    Regs.PC = MemReadWord(Adr+Regs.XR);
+}
+
+
+
 static void OPC_6502_7D (void)
 /* Opcode $7D: ADC abs,x */
 {
     unsigned Addr;
     Cycles = 4;
-    Addr   = MemReadWord (Regs.PC+1);
+    Addr = MemReadWord (Regs.PC+1);
     if (PAGE_CROSS (Addr, Regs.XR)) {
         ++Cycles;
     }
@@ -1179,8 +1455,8 @@ static void OPC_6502_7E (void)
     unsigned Addr;
     unsigned Val;
     Cycles = 7;
-    Addr = MemReadByte (Regs.PC+1) + Regs.XR;
-    Val  = MemReadByte (Addr);
+    Addr = MemReadWord (Regs.PC+1) + Regs.XR;
+    Val = MemReadByte (Addr);
     ROR (Val);
     MemWriteByte (Addr, Val);
     Regs.PC += 3;
@@ -1188,6 +1464,14 @@ static void OPC_6502_7E (void)
 
 
 
+static void OPC_65SC02_80 (void)
+/* Opcode $80: BRA */
+{
+    BRANCH (1);
+}
+
+
+
 static void OPC_6502_81 (void)
 /* Opcode $81: STA (zp,x) */
 {
@@ -1195,7 +1479,7 @@ static void OPC_6502_81 (void)
     unsigned Addr;
     Cycles = 6;
     ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
-    Addr   = MemReadZPWord (ZPAddr);
+    Addr = MemReadZPWord (ZPAddr);
     MemWriteByte (Addr, Regs.AC);
     Regs.PC += 2;
 }
@@ -1250,6 +1534,20 @@ static void OPC_6502_88 (void)
 
 
 
+static void OPC_65SC02_89 (void)
+/* Opcode $89: BIT #imm */
+{
+    unsigned char Val;
+    Cycles = 2;
+    Val = MemReadByte (Regs.PC+1);
+    SET_SF (Val & 0x80);
+    SET_OF (Val & 0x40);
+    SET_ZF ((Val & Regs.AC) == 0);
+    Regs.PC += 2;
+}
+
+
+
 static void OPC_6502_8A (void)
 /* Opcode $8A: TXA */
 {
@@ -1313,7 +1611,21 @@ static void OPC_6502_91 (void)
     unsigned Addr;
     Cycles = 6;
     ZPAddr = MemReadByte (Regs.PC+1);
-    Addr   = MemReadZPWord (ZPAddr) + Regs.YR;
+    Addr = MemReadZPWord (ZPAddr) + Regs.YR;
+    MemWriteByte (Addr, Regs.AC);
+    Regs.PC += 2;
+}
+
+
+
+static void OPC_65SC02_92 (void)
+/* Opcode $92: sta (zp) */
+{
+    unsigned char ZPAddr;
+    unsigned Addr;
+    Cycles = 5;
+    ZPAddr = MemReadByte (Regs.PC+1);
+    Addr = MemReadZPWord (ZPAddr);
     MemWriteByte (Addr, Regs.AC);
     Regs.PC += 2;
 }
@@ -1373,7 +1685,7 @@ static void OPC_6502_99 (void)
 {
     unsigned Addr;
     Cycles = 5;
-    Addr   = MemReadWord (Regs.PC+1) + Regs.YR;
+    Addr = MemReadWord (Regs.PC+1) + Regs.YR;
     MemWriteByte (Addr, Regs.AC);
     Regs.PC += 3;
 }
@@ -1390,18 +1702,42 @@ static void OPC_6502_9A (void)
 
 
 
+static void OPC_65SC02_9C (void)
+/* Opcode $9C: STZ abs */
+{
+    unsigned Addr;
+    Cycles = 4;
+    Addr = MemReadWord (Regs.PC+1);
+    MemWriteByte (Addr, 0);
+    Regs.PC += 3;
+}
+
+
+
 static void OPC_6502_9D (void)
 /* Opcode $9D: STA abs,x */
 {
     unsigned Addr;
     Cycles = 5;
-    Addr   = MemReadWord (Regs.PC+1) + Regs.XR;
+    Addr = MemReadWord (Regs.PC+1) + Regs.XR;
     MemWriteByte (Addr, Regs.AC);
     Regs.PC += 3;
 }
 
 
 
+static void OPC_65SC02_9E (void)
+/* Opcode $9E: STZ abs,x */
+{
+    unsigned Addr;
+    Cycles = 5;
+    Addr = MemReadWord (Regs.PC+1) + Regs.XR;
+    MemWriteByte (Addr, 0);
+    Regs.PC += 3;
+}
+
+
+
 static void OPC_6502_A0 (void)
 /* Opcode $A0: LDY #imm */
 {
@@ -1525,7 +1861,7 @@ static void OPC_6502_AC (void)
 {
     unsigned Addr;
     Cycles = 4;
-    Addr   = MemReadWord (Regs.PC+1);
+    Addr = MemReadWord (Regs.PC+1);
     Regs.YR = MemReadByte (Addr);
     TEST_ZF (Regs.YR);
     TEST_SF (Regs.YR);
@@ -1539,7 +1875,7 @@ static void OPC_6502_AD (void)
 {
     unsigned Addr;
     Cycles = 4;
-    Addr   = MemReadWord (Regs.PC+1);
+    Addr = MemReadWord (Regs.PC+1);
     Regs.AC = MemReadByte (Addr);
     TEST_ZF (Regs.AC);
     TEST_SF (Regs.AC);
@@ -1553,7 +1889,7 @@ static void OPC_6502_AE (void)
 {
     unsigned Addr;
     Cycles = 4;
-    Addr   = MemReadWord (Regs.PC+1);
+    Addr = MemReadWord (Regs.PC+1);
     Regs.XR = MemReadByte (Addr);
     TEST_ZF (Regs.XR);
     TEST_SF (Regs.XR);
@@ -1577,7 +1913,7 @@ static void OPC_6502_B1 (void)
     unsigned Addr;
     Cycles = 5;
     ZPAddr = MemReadByte (Regs.PC+1);
-    Addr   = MemReadZPWord (ZPAddr);
+    Addr = MemReadZPWord (ZPAddr);
     if (PAGE_CROSS (Addr, Regs.YR)) {
         ++Cycles;
     }
@@ -1589,6 +1925,22 @@ static void OPC_6502_B1 (void)
 
 
 
+static void OPC_65SC02_B2 (void)
+/* Opcode $B2: LDA (zp) */
+{
+    unsigned char ZPAddr;
+    unsigned Addr;
+    Cycles = 5;
+    ZPAddr = MemReadByte (Regs.PC+1);
+    Addr = MemReadZPWord (ZPAddr);
+    Regs.AC = MemReadByte (Addr);
+    TEST_ZF (Regs.AC);
+    TEST_SF (Regs.AC);
+    Regs.PC += 2;
+}
+
+
+
 static void OPC_6502_B4 (void)
 /* Opcode $B4: LDY zp,x */
 {
@@ -1662,7 +2014,7 @@ static void OPC_6502_BA (void)
 /* Opcode $BA: TSX */
 {
     Cycles = 2;
-    Regs.XR = Regs.SP;
+    Regs.XR = Regs.SP & 0xFF;
     TEST_ZF (Regs.XR);
     TEST_SF (Regs.XR);
     Regs.PC += 1;
@@ -1738,7 +2090,7 @@ static void OPC_6502_C1 (void)
     unsigned Addr;
     Cycles = 6;
     ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
-    Addr   = MemReadZPWord (ZPAddr);
+    Addr = MemReadZPWord (ZPAddr);
     CMP (Regs.AC, MemReadByte (Addr));
     Regs.PC += 2;
 }
@@ -1776,7 +2128,7 @@ static void OPC_6502_C6 (void)
     unsigned char Val;
     Cycles = 5;
     ZPAddr = MemReadByte (Regs.PC+1);
-    Val    = MemReadByte (ZPAddr) - 1;
+    Val = MemReadByte (ZPAddr) - 1;
     MemWriteByte (ZPAddr, Val);
     TEST_ZF (Val);
     TEST_SF (Val);
@@ -1824,7 +2176,7 @@ static void OPC_6502_CC (void)
 {
     unsigned Addr;
     Cycles = 4;
-    Addr   = MemReadWord (Regs.PC+1);
+    Addr = MemReadWord (Regs.PC+1);
     CMP (Regs.YR, MemReadByte (Addr));
     Regs.PC += 3;
 }
@@ -1836,7 +2188,7 @@ static void OPC_6502_CD (void)
 {
     unsigned Addr;
     Cycles = 4;
-    Addr   = MemReadWord (Regs.PC+1);
+    Addr = MemReadWord (Regs.PC+1);
     CMP (Regs.AC, MemReadByte (Addr));
     Regs.PC += 3;
 }
@@ -1874,7 +2226,7 @@ static void OPC_6502_D1 (void)
     unsigned Addr;
     Cycles = 5;
     ZPAddr = MemReadByte (Regs.PC+1);
-    Addr   = MemReadWord (ZPAddr);
+    Addr = MemReadWord (ZPAddr);
     if (PAGE_CROSS (Addr, Regs.YR)) {
         ++Cycles;
     }
@@ -1884,6 +2236,20 @@ static void OPC_6502_D1 (void)
 
 
 
+static void OPC_65SC02_D2 (void)
+/* Opcode $D2: CMP (zp) */
+{
+    unsigned ZPAddr;
+    unsigned Addr;
+    Cycles = 5;
+    ZPAddr = MemReadByte (Regs.PC+1);
+    Addr = MemReadWord (ZPAddr);
+    CMP (Regs.AC, MemReadByte (Addr));
+    Regs.PC += 2;
+}
+
+
+
 static void OPC_6502_D5 (void)
 /* Opcode $D5: CMP zp,x */
 {
@@ -1937,6 +2303,16 @@ static void OPC_6502_D9 (void)
 
 
 
+static void OPC_65SC02_DA (void)
+/* Opcode $DA: PHX */
+{
+    Cycles = 3;
+    PUSH (Regs.XR);
+    Regs.PC += 1;
+}
+
+
+
 static void OPC_6502_DD (void)
 /* Opcode $DD: CMP abs,x */
 {
@@ -1959,7 +2335,7 @@ static void OPC_6502_DE (void)
     unsigned char Val;
     Cycles = 7;
     Addr = MemReadWord (Regs.PC+1) + Regs.XR;
-    Val  = MemReadByte (Addr) - 1;
+    Val = MemReadByte (Addr) - 1;
     MemWriteByte (Addr, Val);
     TEST_ZF (Val);
     TEST_SF (Val);
@@ -1985,7 +2361,7 @@ static void OPC_6502_E1 (void)
     unsigned Addr;
     Cycles = 6;
     ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
-    Addr   = MemReadZPWord (ZPAddr);
+    Addr = MemReadZPWord (ZPAddr);
     SBC (MemReadByte (Addr));
     Regs.PC += 2;
 }
@@ -2023,7 +2399,7 @@ static void OPC_6502_E6 (void)
     unsigned char Val;
     Cycles = 5;
     ZPAddr = MemReadByte (Regs.PC+1);
-    Val    = MemReadByte (ZPAddr) + 1;
+    Val = MemReadByte (ZPAddr) + 1;
     MemWriteByte (ZPAddr, Val);
     TEST_ZF (Val);
     TEST_SF (Val);
@@ -2064,6 +2440,42 @@ static void OPC_6502_EA (void)
 
 
 
+static void OPC_65C02_NOP11(void)
+/* Opcode 'Illegal' 1 cycle NOP */
+{
+    Cycles = 1;
+    Regs.PC += 1;
+}
+
+
+
+static void OPC_65C02_NOP22 (void)
+/* Opcode 'Illegal' 2 byte 2 cycle NOP */
+{
+    Cycles = 2;
+    Regs.PC += 2;
+}
+
+
+
+static void OPC_65C02_NOP24 (void)
+/* Opcode 'Illegal' 2 byte 4 cycle NOP */
+{
+    Cycles = 4;
+    Regs.PC += 2;
+}
+
+
+
+static void OPC_65C02_NOP34 (void)
+/* Opcode 'Illegal' 3 byte 4 cycle NOP */
+{
+    Cycles = 4;
+    Regs.PC += 3;
+}
+
+
+
 static void OPC_6502_EC (void)
 /* Opcode $EC: CPX abs */
 {
@@ -2081,7 +2493,7 @@ static void OPC_6502_ED (void)
 {
     unsigned Addr;
     Cycles = 4;
-    Addr   = MemReadWord (Regs.PC+1);
+    Addr = MemReadWord (Regs.PC+1);
     SBC (MemReadByte (Addr));
     Regs.PC += 3;
 }
@@ -2095,7 +2507,7 @@ static void OPC_6502_EE (void)
     unsigned char Val;
     Cycles = 6;
     Addr = MemReadWord (Regs.PC+1);
-    Val  = MemReadByte (Addr) + 1;
+    Val = MemReadByte (Addr) + 1;
     MemWriteByte (Addr, Val);
     TEST_ZF (Val);
     TEST_SF (Val);
@@ -2119,7 +2531,7 @@ static void OPC_6502_F1 (void)
     unsigned Addr;
     Cycles = 5;
     ZPAddr = MemReadByte (Regs.PC+1);
-    Addr   = MemReadZPWord (ZPAddr);
+    Addr = MemReadZPWord (ZPAddr);
     if (PAGE_CROSS (Addr, Regs.YR)) {
         ++Cycles;
     }
@@ -2129,6 +2541,20 @@ static void OPC_6502_F1 (void)
 
 
 
+static void OPC_65SC02_F2 (void)
+/* Opcode $F2: SBC (zp) */
+{
+    unsigned char ZPAddr;
+    unsigned Addr;
+    Cycles = 5;
+    ZPAddr = MemReadByte (Regs.PC+1);
+    Addr = MemReadZPWord (ZPAddr);
+    SBC (MemReadByte (Addr));
+    Regs.PC += 2;
+}
+
+
+
 static void OPC_6502_F5 (void)
 /* Opcode $F5: SBC zp,x */
 {
@@ -2148,7 +2574,7 @@ static void OPC_6502_F6 (void)
     unsigned char Val;
     Cycles = 6;
     ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
-    Val  = MemReadByte (ZPAddr) + 1;
+    Val = MemReadByte (ZPAddr) + 1;
     MemWriteByte (ZPAddr, Val);
     TEST_ZF (Val);
     TEST_SF (Val);
@@ -2160,7 +2586,9 @@ static void OPC_6502_F6 (void)
 static void OPC_6502_F8 (void)
 /* Opcode $F8: SED */
 {
+    Cycles = 2;
     SET_DF (1);
+    Regs.PC += 1;
 }
 
 
@@ -2170,7 +2598,7 @@ static void OPC_6502_F9 (void)
 {
     unsigned Addr;
     Cycles = 4;
-    Addr   = MemReadWord (Regs.PC+1);
+    Addr = MemReadWord (Regs.PC+1);
     if (PAGE_CROSS (Addr, Regs.YR)) {
         ++Cycles;
     }
@@ -2180,12 +2608,24 @@ static void OPC_6502_F9 (void)
 
 
 
+static void OPC_65SC02_FA (void)
+/* Opcode $7A: PLX */
+{
+    Cycles = 4;
+    Regs.XR = POP ();
+    TEST_ZF (Regs.XR);
+    TEST_SF (Regs.XR);
+    Regs.PC += 1;
+}
+
+
+
 static void OPC_6502_FD (void)
 /* Opcode $FD: SBC abs,x */
 {
     unsigned Addr;
     Cycles = 4;
-    Addr   = MemReadWord (Regs.PC+1);
+    Addr = MemReadWord (Regs.PC+1);
     if (PAGE_CROSS (Addr, Regs.XR)) {
         ++Cycles;
     }
@@ -2202,7 +2642,7 @@ static void OPC_6502_FE (void)
     unsigned char Val;
     Cycles = 7;
     Addr = MemReadWord (Regs.PC+1) + Regs.XR;
-    Val  = MemReadByte (Addr) + 1;
+    Val = MemReadByte (Addr) + 1;
     MemWriteByte (Addr, Val);
     TEST_ZF (Val);
     TEST_SF (Val);
@@ -2483,260 +2923,260 @@ static const OPFunc OP6502Table[256] = {
 static const OPFunc OP65C02Table[256] = {
     OPC_6502_00,
     OPC_6502_01,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65C02_NOP22,    // $02
+    OPC_65C02_NOP11,    // $03
+    OPC_65SC02_04,
     OPC_6502_05,
     OPC_6502_06,
-    OPC_Illegal,
+    OPC_Illegal,        // $07: RMB0 currently unsupported
     OPC_6502_08,
     OPC_6502_09,
     OPC_6502_0A,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65C02_NOP11,    // $0B
+    OPC_65SC02_0C,
     OPC_6502_0D,
     OPC_6502_0E,
-    OPC_Illegal,
+    OPC_Illegal,        // $0F: BBR0 currently unsupported
     OPC_6502_10,
     OPC_6502_11,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_12,
+    OPC_65C02_NOP11,    // $13
+    OPC_65SC02_14,
     OPC_6502_15,
     OPC_6502_16,
-    OPC_Illegal,
+    OPC_Illegal,        // $17: RMB1 currently unsupported
     OPC_6502_18,
     OPC_6502_19,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_1A,
+    OPC_65C02_NOP11,    // $1B
+    OPC_65SC02_1C,
     OPC_6502_1D,
     OPC_6502_1E,
-    OPC_Illegal,
+    OPC_Illegal,        // $1F: BBR1 currently unsupported
     OPC_6502_20,
     OPC_6502_21,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65C02_NOP22,    // $22
+    OPC_65C02_NOP11,    // $23
     OPC_6502_24,
     OPC_6502_25,
     OPC_6502_26,
-    OPC_Illegal,
+    OPC_Illegal,        // $27: RMB2 currently unsupported
     OPC_6502_28,
     OPC_6502_29,
     OPC_6502_2A,
-    OPC_Illegal,
+    OPC_65C02_NOP11,    // $2B
     OPC_6502_2C,
     OPC_6502_2D,
     OPC_6502_2E,
-    OPC_Illegal,
+    OPC_Illegal,        // $2F: BBR2 currently unsupported
     OPC_6502_30,
     OPC_6502_31,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_32,
+    OPC_65C02_NOP11,    // $33
+    OPC_65SC02_34,
     OPC_6502_35,
     OPC_6502_36,
-    OPC_Illegal,
+    OPC_Illegal,        // $37: RMB3 currently unsupported
     OPC_6502_38,
     OPC_6502_39,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_3A,
+    OPC_65C02_NOP11,    // $3B
+    OPC_65SC02_3C,
     OPC_6502_3D,
     OPC_6502_3E,
-    OPC_Illegal,
+    OPC_Illegal,        // $3F: BBR3 currently unsupported
     OPC_6502_40,
     OPC_6502_41,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65C02_NOP22,    // $42
+    OPC_65C02_NOP11,    // $43
+    OPC_65C02_44,       // $44
     OPC_6502_45,
     OPC_6502_46,
-    OPC_Illegal,
+    OPC_Illegal,        // $47: RMB4 currently unsupported
     OPC_6502_48,
     OPC_6502_49,
     OPC_6502_4A,
-    OPC_Illegal,
+    OPC_65C02_NOP11,    // $4B
     OPC_6502_4C,
     OPC_6502_4D,
     OPC_6502_4E,
-    OPC_Illegal,
+    OPC_Illegal,        // $4F: BBR4 currently unsupported
     OPC_6502_50,
     OPC_6502_51,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_52,
+    OPC_65C02_NOP11,    // $53
+    OPC_65C02_NOP24,    // $54
     OPC_6502_55,
     OPC_6502_56,
-    OPC_Illegal,
+    OPC_Illegal,        // $57: RMB5 currently unsupported
     OPC_6502_58,
     OPC_6502_59,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_5A,
+    OPC_65C02_NOP11,    // $5B
+    OPC_65C02_5C,
     OPC_6502_5D,
     OPC_6502_5E,
-    OPC_Illegal,
+    OPC_Illegal,        // $5F: BBR5 currently unsupported
     OPC_6502_60,
     OPC_6502_61,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65C02_NOP22,    // $62
+    OPC_65C02_NOP11,    // $63
+    OPC_65SC02_64,
     OPC_6502_65,
     OPC_6502_66,
-    OPC_Illegal,
+    OPC_Illegal,        // $67: RMB6 currently unsupported
     OPC_6502_68,
     OPC_6502_69,
     OPC_6502_6A,
-    OPC_Illegal,
+    OPC_65C02_NOP11,    // $6B
     OPC_65C02_6C,
     OPC_6502_6D,
     OPC_6502_6E,
-    OPC_Illegal,
+    OPC_Illegal,        // $6F: BBR6 currently unsupported
     OPC_6502_70,
     OPC_6502_71,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_72,
+    OPC_65C02_NOP11,    // $73
+    OPC_65SC02_74,
     OPC_6502_75,
     OPC_6502_76,
-    OPC_Illegal,
+    OPC_Illegal,        // $77: RMB7 currently unsupported
     OPC_6502_78,
     OPC_6502_79,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_7A,
+    OPC_65C02_NOP11,    // $7B
+    OPC_65SC02_7C,
     OPC_6502_7D,
     OPC_6502_7E,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_Illegal,        // $7F: BBR7 currently unsupported
+    OPC_65SC02_80,
     OPC_6502_81,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65C02_NOP22,    // $82
+    OPC_65C02_NOP11,    // $83
     OPC_6502_84,
     OPC_6502_85,
     OPC_6502_86,
-    OPC_Illegal,
+    OPC_Illegal,        // $87: SMB0 currently unsupported
     OPC_6502_88,
-    OPC_Illegal,
+    OPC_65SC02_89,
     OPC_6502_8A,
-    OPC_Illegal,
+    OPC_65C02_NOP11,    // $8B
     OPC_6502_8C,
     OPC_6502_8D,
     OPC_6502_8E,
-    OPC_Illegal,
+    OPC_Illegal,        // $8F: BBS0 currently unsupported
     OPC_6502_90,
     OPC_6502_91,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_92,
+    OPC_65C02_NOP11,    // $93
     OPC_6502_94,
     OPC_6502_95,
     OPC_6502_96,
-    OPC_Illegal,
+    OPC_Illegal,        // $97: SMB1 currently unsupported
     OPC_6502_98,
     OPC_6502_99,
     OPC_6502_9A,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65C02_NOP11,    // $9B
+    OPC_65SC02_9C,
     OPC_6502_9D,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_9E,
+    OPC_Illegal,        // $9F: BBS1 currently unsupported
     OPC_6502_A0,
     OPC_6502_A1,
     OPC_6502_A2,
-    OPC_Illegal,
+    OPC_65C02_NOP11,    // $A3
     OPC_6502_A4,
     OPC_6502_A5,
     OPC_6502_A6,
-    OPC_Illegal,
+    OPC_Illegal,        // $A7: SMB2 currently unsupported
     OPC_6502_A8,
     OPC_6502_A9,
     OPC_6502_AA,
-    OPC_Illegal,
+    OPC_65C02_NOP11,    // $AB
     OPC_6502_AC,
     OPC_6502_AD,
     OPC_6502_AE,
-    OPC_Illegal,
+    OPC_Illegal,        // $AF: BBS2 currently unsupported
     OPC_6502_B0,
     OPC_6502_B1,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_B2,
+    OPC_65C02_NOP11,    // $B3
     OPC_6502_B4,
     OPC_6502_B5,
     OPC_6502_B6,
-    OPC_Illegal,
+    OPC_Illegal,        // $B7: SMB3 currently unsupported
     OPC_6502_B8,
     OPC_6502_B9,
     OPC_6502_BA,
-    OPC_Illegal,
+    OPC_65C02_NOP11,    // $BB
     OPC_6502_BC,
     OPC_6502_BD,
     OPC_6502_BE,
-    OPC_Illegal,
+    OPC_Illegal,        // $BF: BBS3 currently unsupported
     OPC_6502_C0,
     OPC_6502_C1,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65C02_NOP22,    // $C2
+    OPC_65C02_NOP11,    // $C3
     OPC_6502_C4,
     OPC_6502_C5,
     OPC_6502_C6,
-    OPC_Illegal,
+    OPC_Illegal,        // $C7: SMB4 currently unsupported
     OPC_6502_C8,
     OPC_6502_C9,
     OPC_6502_CA,
-    OPC_Illegal,
+    OPC_Illegal,        // $CB: WAI currently unsupported
     OPC_6502_CC,
     OPC_6502_CD,
     OPC_6502_CE,
-    OPC_Illegal,
+    OPC_Illegal,        // $CF: BBS4 currently unsupported
     OPC_6502_D0,
     OPC_6502_D1,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_D2,
+    OPC_65C02_NOP11,    // $D3
+    OPC_65C02_NOP24,    // $D4
     OPC_6502_D5,
     OPC_6502_D6,
-    OPC_Illegal,
+    OPC_Illegal,        // $D7: SMB5 currently unsupported
     OPC_6502_D8,
     OPC_6502_D9,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_DA,
+    OPC_Illegal,        // $DB: STP currently unsupported
+    OPC_65C02_NOP34,    // $DC
     OPC_6502_DD,
     OPC_6502_DE,
-    OPC_Illegal,
+    OPC_Illegal,        // $DF: BBS5 currently unsupported
     OPC_6502_E0,
     OPC_6502_E1,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65C02_NOP22,    // $E2
+    OPC_65C02_NOP11,    // $E3
     OPC_6502_E4,
     OPC_6502_E5,
     OPC_6502_E6,
-    OPC_Illegal,
+    OPC_Illegal,        // $E7: SMB6 currently unsupported
     OPC_6502_E8,
     OPC_6502_E9,
     OPC_6502_EA,
-    OPC_Illegal,
+    OPC_65C02_NOP11,    // $EB
     OPC_6502_EC,
     OPC_6502_ED,
     OPC_6502_EE,
-    OPC_Illegal,
+    OPC_Illegal,        // $EF: BBS6 currently unsupported
     OPC_6502_F0,
     OPC_6502_F1,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_F2,
+    OPC_65C02_NOP11,    // $F3
+    OPC_65C02_NOP24,    // $F4
     OPC_6502_F5,
     OPC_6502_F6,
-    OPC_Illegal,
+    OPC_Illegal,        // $F7: SMB7 currently unsupported
     OPC_6502_F8,
     OPC_6502_F9,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_FA,
+    OPC_65C02_NOP11,    // $FB
+    OPC_65C02_NOP34,    // $FC
     OPC_6502_FD,
     OPC_6502_FE,
-    OPC_Illegal,
+    OPC_Illegal,        // $FF: BBS7 currently unsupported
 };
 
 
@@ -2776,7 +3216,9 @@ void Reset (void)
     /* Reset the CPU */
     HaveIRQRequest = 0;
     HaveNMIRequest = 0;
-    Regs.SR = 0;
+
+    /* Bits 5 and 4 aren't used, and always are 1! */
+    Regs.SR = 0x30;
     Regs.PC = MemReadWord (0xFFFC);
 }
 
@@ -2791,8 +3233,12 @@ unsigned ExecuteInsn (void)
         HaveNMIRequest = 0;
         PUSH (PCH);
         PUSH (PCL);
-        PUSH (Regs.SR);
+        PUSH (Regs.SR & ~BF);
         SET_IF (1);
+        if (CPU != CPU_6502)
+        {
+            SET_DF (0);
+        }
         Regs.PC = MemReadWord (0xFFFA);
         Cycles = 7;
 
@@ -2801,8 +3247,12 @@ unsigned ExecuteInsn (void)
         HaveIRQRequest = 0;
         PUSH (PCH);
         PUSH (PCL);
-        PUSH (Regs.SR);
+        PUSH (Regs.SR & ~BF);
         SET_IF (1);
+        if (CPU != CPU_6502)
+        {
+            SET_DF (0);
+        }
         Regs.PC = MemReadWord (0xFFFE);
         Cycles = 7;
 
index db026af48a623863b56a7e9e8a8b5bfd770fb4cc..e57b86973f69d13123226eafd9d4a85c3c77205c 100644 (file)
@@ -240,7 +240,7 @@ void SplitAddAttr (Collection* C, const char* Combined, const char* Name)
 
 
 
-Collection* ParseAttrList (const char* List, const char** NameList, unsigned NameCount)
+Collection* ParseAttrList (const char* List, const char* const* NameList, unsigned NameCount)
 /* Parse a list containing name/value pairs into a sorted collection. Some
 ** attributes may not need a name, so NameList contains these names. If there
 ** were no errors, the function returns a alphabetically sorted collection
index 2b7ce68b9a995b75dcc11e3e14e754fe68f7b413..e93bcd9371d9e7149ee861a17b3cd9b0ad2c08d3 100644 (file)
@@ -111,7 +111,7 @@ void SplitAddAttr (Collection* C, const char* Combined, const char* Name);
 ** Name is NULL, terminate with an error.
 */
 
-Collection* ParseAttrList (const char* List, const char** NameList, unsigned NameCount);
+Collection* ParseAttrList (const char* List, const char* const* NameList, unsigned NameCount);
 /* Parse a list containing name/value pairs into a sorted collection. Some
 ** attributes may not need a name, so NameList contains these names. If there
 ** were no errors, the function returns a alphabetically sorted collection
index 828a48fc8f70e858cd29ec63aaaa9095362580c5..5c9724a8ab78057779ad61de9a60a3cbc631f191 100644 (file)
@@ -141,7 +141,7 @@ static void SetOutputData (StrBuf* N)
 static void OptConvertTo (const char* Opt attribute ((unused)), const char* Arg)
 /* Convert the bitmap into a target format */
 {
-    static const char* NameList[] = {
+    static const char* const NameList[] = {
         "format"
     };
 
@@ -220,7 +220,7 @@ static void OptPop (const char* Opt attribute ((unused)),
 static void OptRead (const char* Opt attribute ((unused)), const char* Arg)
 /* Read an input file */
 {
-    static const char* NameList[] = {
+    static const char* const NameList[] = {
         "name", "format"
     };
 
@@ -294,7 +294,7 @@ static void OptVersion (const char* Opt attribute ((unused)),
 static void OptWrite (const char* Opt attribute ((unused)), const char* Arg)
 /* Write an output file */
 {
-    static const char* NameList[] = {
+    static const char* const NameList[] = {
         "name", "format"
     };
 
index 4817e70e0ff103ce6692c9901578e7a81b1d34bc..c858835171d3cfb169d5f60e7303800f688569c1 100644 (file)
@@ -1,51 +1,36 @@
-
-# top-level makefile for the regression tests
-
-# You can comment this special target when you debug the regression tests.
-# Then, make will give you more progress reports.
-.SILENT:
+# top-level Makefile for the regression tests
 
 ifneq ($(shell echo),)
-  CMD_EXE := 1
+  CMD_EXE = 1
 endif
 
 ifdef CMD_EXE
-  EXE := .exe
-  MKDIR = mkdir $(subst /,\,$1)
   RMDIR = -rmdir /s /q $(subst /,\,$1)
 else
-  EXE :=
-  MKDIR = mkdir $1
   RMDIR = $(RM) -r $1
 endif
 
-WORKDIR := ../testwrk
-
-CC := gcc
+WORKDIR = ../testwrk
 
 .PHONY: all dotests continue mostlyclean clean
 
 all: dotests
 
-$(WORKDIR):
-       $(call MKDIR,$(WORKDIR))
-
-$(WORKDIR)/bdiff$(EXE): bdiff.c | $(WORKDIR)
-       $(CC) -O2 -o $@ $<
-
 .NOTPARALLEL:
 
 dotests: mostlyclean continue
 
-continue: $(WORKDIR)/bdiff$(EXE)
-       @$(MAKE) -C assembler all
-       @$(MAKE) -C disassembler all
+continue:
+       @$(MAKE) -C asm all
+       @$(MAKE) -C dasm all
        @$(MAKE) -C val all
        @$(MAKE) -C ref all
        @$(MAKE) -C err all
        @$(MAKE) -C misc all
 
 mostlyclean:
+       @$(MAKE) -C asm clean
+       @$(MAKE) -C dasm clean
        @$(MAKE) -C val clean
        @$(MAKE) -C ref clean
        @$(MAKE) -C err clean
diff --git a/test/asm/4510-cpudetect.ref b/test/asm/4510-cpudetect.ref
new file mode 100644 (file)
index 0000000..515557c
Binary files /dev/null and b/test/asm/4510-cpudetect.ref differ
diff --git a/test/asm/4510-opcodes.ref b/test/asm/4510-opcodes.ref
new file mode 100644 (file)
index 0000000..b65b12e
Binary files /dev/null and b/test/asm/4510-opcodes.ref differ
diff --git a/test/asm/4510-opcodes.s b/test/asm/4510-opcodes.s
new file mode 100644 (file)
index 0000000..3d68056
--- /dev/null
@@ -0,0 +1,278 @@
+.setcpu "4510"
+
+   brk
+   ora ($05,x)
+   cle
+   see
+   tsb $02
+   ora $02
+   asl $02
+   rmb0 $02
+   php
+   ora #$01
+   asl
+   tsy
+   tsb $1234
+   ora $1234
+   asl $1234
+   bbr0 $02,*+$34
+
+   bpl *+$32
+   ora ($06),y
+   ora ($07),z
+   lbpl *+$3133 ; bpl *+$3133
+   trb $02
+   ora $03,x
+   asl $03,x
+   rmb1 $02
+   clc
+   ora $1456,y
+   inc
+   inz
+   trb $1234
+   ora $1345,x
+   asl $1345,x
+   bbr1 $02,*+$34
+
+   jsr $1234
+   and ($05,x)
+   jsr ($2345)
+   jsr ($2456,x)
+   bit $02
+   and $02
+   rol $02
+   rmb2 $02
+   plp
+   and #$01
+   rol
+   tys
+   bit $1234
+   and $1234
+   rol $1234
+   bbr2 $02,*+$34
+
+   bmi *+$32
+   and ($06),y
+   and ($07),z
+   lbmi *+$3133 ; bmi *+$3133
+   bit $03,x
+   and $03,x
+   rol $03,x
+   rmb3 $02
+   sec
+   and $1456,y
+   dec
+   dez
+   bit $1345,x
+   and $1345,x
+   rol $1345,x
+   bbr3 $02,*+$34
+
+   rti
+   eor ($05,x)
+   neg
+   asr
+   asr $02
+   eor $02
+   lsr $02
+   rmb4 $02
+   pha
+   eor #$01
+   lsr
+   taz
+   jmp $1234
+   eor $1234
+   lsr $1234
+   bbr4 $02,*+$34
+
+   bvc *+$32
+   eor ($06),y
+   eor ($07),z
+   lbvc *+$3133 ; bvc *+$3133
+   asr $03,x
+   eor $03,x
+   lsr $03,x
+   rmb5 $02
+   cli
+   eor $1456,y
+   phy
+   tab
+   map
+   eor $1345,x
+   lsr $1345,x
+   bbr5 $02,*+$34
+
+   rts
+   adc ($05,x)
+   rtn #$09
+   bsr *+$3133
+   stz $02
+   adc $02
+   ror $02
+   rmb6 $02
+   pla
+   adc #$01
+   ror
+   tza
+   jmp ($2345)
+   adc $1234
+   ror $1234
+   bbr6 $02,*+$34
+
+   bvs *+$32
+   adc ($06),y
+   adc ($07),z
+   lbvs *+$3133 ; bvs *+$3133
+   stz $03,x
+   adc $03,x
+   ror $03,x
+   rmb7 $02
+   sei
+   adc $1456,y
+   ply
+   tba
+   jmp ($2456,x)
+   adc $1345,x
+   ror $1345,x
+   bbr7 $02,*+$34
+
+   bra *+$32
+   sta ($05,x)
+   sta ($0f,s),y
+   sta ($0f,sp),y
+   lbra *+$3133 ; bra *+$3133
+   sty $02
+   sta $02
+   stx $02
+   smb0 $02
+   dey
+   bit #$01
+   txa
+   sty $1345,x
+   sty $1234
+   sta $1234
+   stx $1234
+   bbs0 $02,*+$34
+
+   bcc *+$32
+   sta ($06),y
+   sta ($07),z
+   lbcc *+$3133 ; bcc *+$3133
+   sty $03,x
+   sta $03,x
+   stx $04,y
+   smb1 $02
+   tya
+   sta $1456,y
+   txs
+   stx $1456,y
+   stz $1234
+   sta $1345,x
+   stz $1345,x
+   bbs1 $02,*+$34
+
+   ldy #$01
+   lda ($05,x)
+   ldx #$01
+   ldz #$01
+   ldy $02
+   lda $02
+   ldx $02
+   smb2 $02
+   tay
+   lda #$01
+   tax
+   ldz $1234
+   ldy $1234
+   lda $1234
+   ldx $1234
+   bbs2 $02,*+$34
+
+   bcs *+$32
+   lda ($06),y
+   lda ($07),z
+   lbcs *+$3133 ; bcs *+$3133
+   ldy $03,x
+   lda $03,x
+   ldx $04,y
+   smb3 $02
+   clv
+   lda $1456,y
+   tsx
+   ldz $1345,x
+   ldy $1345,x
+   lda $1345,x
+   ldx $1456,y
+   bbs3 $02,*+$34
+
+   cpy #$01
+   cmp ($05,x)
+   cpz #$01
+   dew $02
+   cpy $02
+   cmp $02
+   dec $02
+   smb4 $02
+   iny
+   cmp #$01
+   dex
+   asw $1234
+   cpy $1234
+   cmp $1234
+   dec $1234
+   bbs4 $02,*+$34
+
+   bne *+$32
+   cmp ($06),y
+   cmp ($07),z
+   lbne *+$3133 ; bne *+$3133
+   cpz $02
+   cmp $03,x
+   dec $03,x
+   smb5 $02
+   cld
+   cmp $1456,y
+   phx
+   phz
+   cpz $1234
+   cmp $1345,x
+   dec $1345,x
+   bbs5 $02,*+$34
+
+   cpx #$01
+   sbc ($05,x)
+   lda ($0f,s),y
+   lda ($0f,sp),y
+   inw $02
+   cpx $02
+   sbc $02
+   inc $02
+   smb6 $02
+   inx
+   sbc #$01
+   eom
+   nop
+   row $1234
+   cpx $1234
+   sbc $1234
+   inc $1234
+   bbs6 $02,*+$34
+
+   beq *+$32
+   sbc ($06),y
+   sbc ($07),z
+   lbeq *+$3133 ; beq *+$3133
+   phd #$089a
+   phw #$089a
+   sbc $03,x
+   inc $03,x
+   smb7 $02
+   sed
+   sbc $1456,y
+   plx
+   plz
+   phd $1234
+   phw $1234
+   sbc $1345,x
+   inc $1345,x
+   bbs7 $02,*+$34
diff --git a/test/asm/6502-cpudetect.ref b/test/asm/6502-cpudetect.ref
new file mode 100644 (file)
index 0000000..9b0aeb1
Binary files /dev/null and b/test/asm/6502-cpudetect.ref differ
diff --git a/test/asm/6502-opcodes.ref b/test/asm/6502-opcodes.ref
new file mode 100644 (file)
index 0000000..c12fa8f
Binary files /dev/null and b/test/asm/6502-opcodes.ref differ
diff --git a/test/asm/6502-opcodes.s b/test/asm/6502-opcodes.s
new file mode 100644 (file)
index 0000000..5cb94c2
--- /dev/null
@@ -0,0 +1,257 @@
+.setcpu "6502"
+
+   brk
+   ora     ($12,x)
+   .byte   $02
+   .byte   $03
+   .byte   $04
+   ora     $12
+   asl     $12
+   .byte   $07
+   php
+   ora     #$12
+   asl     a
+   .byte   $0B
+   .byte   $0C
+   ora     $3456
+   asl     $3456
+   .byte   $0F
+   bpl     *+122
+   ora     ($12),y
+   .byte   $12
+   .byte   $13
+   .byte   $14
+   ora     $12,x
+   asl     $12,x
+   .byte   $17
+   clc
+   ora     $3456,y
+   .byte   $1A
+   .byte   $1B
+   .byte   $1C
+   ora     $3456,x
+   asl     $3456,x
+   .byte   $1F
+   jsr     $3456
+   and     ($12,x)
+   .byte   $22
+   .byte   $23
+   bit     $12
+   and     $12
+   rol     $12
+   .byte   $27
+   plp
+   and     #$12
+   rol     a
+   .byte   $2B
+   bit     $3456
+   and     $3456
+   rol     $3456
+   .byte   $2F
+   bmi     *+122
+   and     ($12),y
+   .byte   $32
+   .byte   $33
+   .byte   $34
+   and     $12,x
+   rol     $12,x
+   .byte   $37
+   sec
+   and     $3456,y
+   .byte   $3A
+   .byte   $3B
+   .byte   $3C
+   and     $3456,x
+   rol     $3456,x
+   .byte   $3F
+   rti
+   eor     ($12,x)
+   .byte   $42
+   .byte   $43
+   .byte   $44
+   eor     $12
+   lsr     $12
+   .byte   $47
+   pha
+   eor     #$12
+   lsr     a
+   .byte   $4B
+   jmp     $3456
+   eor     $3456
+   lsr     $3456
+   .byte   $4F
+   bvc     *+122
+   eor     ($12),y
+   .byte   $52
+   .byte   $53
+   .byte   $54
+   eor     $12,x
+   lsr     $12,x
+   .byte   $57
+   cli
+   eor     $3456,y
+   .byte   $5A
+   .byte   $5B
+   .byte   $5C
+   eor     $3456,x
+   lsr     $3456,x
+   .byte   $5F
+   rts
+   adc     ($12,x)
+   .byte   $62
+   .byte   $63
+   .byte   $64
+   adc     $12
+   ror     $12
+   .byte   $67
+   pla
+   adc     #$12
+   ror     a
+   .byte   $6B
+   jmp     ($3456)
+   adc     $3456
+   ror     $3456
+   .byte   $6F
+   bvs     *+122
+   adc     ($12),y
+   .byte   $72
+   .byte   $73
+   .byte   $74
+   adc     $12,x
+   ror     $12,x
+   .byte   $77
+   sei
+   adc     $3456,y
+   .byte   $7A
+   .byte   $7B
+   .byte   $7C
+   adc     $3456,x
+   ror     $3456,x
+   .byte   $7F
+   .byte   $80
+   sta     ($12,x)
+   .byte   $82
+   .byte   $83
+   sty     $12
+   sta     $12
+   stx     $12
+   .byte   $87
+   dey
+   .byte   $89
+   txa
+   .byte   $8B
+   sty     $3456
+   sta     $3456
+   stx     $3456
+   .byte   $8F
+   bcc     *+122
+   sta     ($12),y
+   .byte   $92
+   .byte   $93
+   sty     $12,x
+   sta     $12,x
+   stx     $12,y
+   .byte   $97
+   tya
+   sta     $3456,y
+   txs
+   .byte   $9B
+   .byte   $9C
+   sta     $3456,x
+   .byte   $9E
+   .byte   $9F
+   ldy     #$12
+   lda     ($12,x)
+   ldx     #$12
+   .byte   $A3
+   ldy     $12
+   lda     $12
+   ldx     $12
+   .byte   $A7
+   tay
+   lda     #$12
+   tax
+   .byte   $AB
+   ldy     $3456
+   lda     $3456
+   ldx     $3456
+   .byte   $AF
+   bcs     *+122
+   lda     ($12),y
+   .byte   $B2
+   .byte   $B3
+   ldy     $12,x
+   lda     $12,x
+   ldx     $12,y
+   .byte   $B7
+   clv
+   lda     $3456,y
+   tsx
+   .byte   $BB
+   ldy     $3456,x
+   lda     $3456,x
+   ldx     $3456,y
+   .byte   $BF
+   cpy     #$12
+   cmp     ($12,x)
+   .byte   $C2
+   .byte   $C3
+   cpy     $12
+   cmp     $12
+   dec     $12
+   .byte   $C7
+   iny
+   cmp     #$12
+   dex
+   .byte   $CB
+   cpy     $3456
+   cmp     $3456
+   dec     $3456
+   .byte   $CF
+   bne     *+122
+   cmp     ($12),y
+   .byte   $D2
+   .byte   $D3
+   .byte   $D4
+   cmp     $12,x
+   dec     $12,x
+   .byte   $D7
+   cld
+   cmp     $3456,y
+   .byte   $DA
+   .byte   $DB
+   .byte   $DC
+   cmp     $3456,x
+   dec     $3456,x
+   .byte   $DF
+   cpx     #$12
+   sbc     ($12,x)
+   .byte   $E2
+   .byte   $E3
+   cpx     $12
+   sbc     $12
+   inc     $12
+   .byte   $E7
+   inx
+   sbc     #$12
+   .byte   $EB
+   cpx     $3456
+   sbc     $3456
+   inc     $3456
+   .byte   $EF
+   beq     *+122
+   sbc     ($12),y
+   .byte   $F2
+   .byte   $F3
+   .byte   $F4
+   sbc     $12,x
+   inc     $12,x
+   .byte   $F7
+   sed
+   sbc     $3456,y
+   .byte   $FA
+   .byte   $FB
+   .byte   $FC
+   sbc     $3456,x
+   inc     $3456,x
+   .byte   $FF
diff --git a/test/asm/6502x-cpudetect.ref b/test/asm/6502x-cpudetect.ref
new file mode 100644 (file)
index 0000000..3434ecb
Binary files /dev/null and b/test/asm/6502x-cpudetect.ref differ
diff --git a/test/asm/6502x-opcodes.ref b/test/asm/6502x-opcodes.ref
new file mode 100644 (file)
index 0000000..f942bec
Binary files /dev/null and b/test/asm/6502x-opcodes.ref differ
diff --git a/test/asm/6502x-opcodes.s b/test/asm/6502x-opcodes.s
new file mode 100644 (file)
index 0000000..5f21aeb
--- /dev/null
@@ -0,0 +1,258 @@
+.setcpu "6502X"
+
+   brk
+   ora     ($12,x)
+   jam
+   slo     ($12,x)
+   nop     $12
+   ora     $12
+   asl     $12
+   slo     $12
+   php
+   ora     #$12
+   asl     a
+   anc     #$12
+   nop     $3456
+   ora     $3456
+   asl     $3456
+   slo     $3456
+   bpl     *+122
+   ora     ($12),y
+   .byte   $12         ; jam
+   slo     ($12),y
+   nop     $12,x
+   ora     $12,x
+   asl     $12,x
+   slo     $12,x
+   clc
+   ora     $3456,y
+   .byte   $1a         ; nop
+   slo     $3456,y
+   nop     $3456,x
+   ora     $3456,x
+   asl     $3456,x
+   slo     $3456,x
+   jsr     $3456
+   and     ($12,x)
+   .byte   $22         ; jam
+   rla     ($12,x)
+   bit     $12
+   and     $12
+   rol     $12
+   rla     $12
+   plp
+   and     #$12
+   rol     a
+   .byte   $2b         ; anc     #$12
+   bit     $3456
+   and     $3456
+   rol     $3456
+   rla     $3456
+   bmi     *+122
+   and     ($12),y
+   .byte   $32         ; jam
+   rla     ($12),y
+   .byte   $34,$12     ; nop     $12,x
+   and     $12,x
+   rol     $12,x
+   rla     $12,x
+   sec
+   and     $3456,y
+   .byte   $3a         ; nop
+   rla     $3456,y
+   .byte   $3c,$56,$34 ; nop     $3456,x
+   and     $3456,x
+   rol     $3456,x
+   rla     $3456,x
+   rti
+   eor     ($12,x)
+   .byte   $42         ; jam
+   sre     ($12,x)
+   .byte   $44,$12     ; nop     $12
+   eor     $12
+   lsr     $12
+   sre     $12
+   pha
+   eor     #$12
+   lsr     a
+   alr     #$12
+   jmp     $3456
+   eor     $3456
+   lsr     $3456
+   sre     $3456
+   bvc     *+122
+   eor     ($12),y
+   .byte   $52         ; jam
+   sre     ($12),y
+   .byte   $54,$12     ; nop     $12,x
+   eor     $12,x
+   lsr     $12,x
+   sre     $12,x
+   cli
+   eor     $3456,y
+   .byte   $5a         ; nop
+   sre     $3456,y
+   nop     $3456,x
+   eor     $3456,x
+   lsr     $3456,x
+   sre     $3456,x
+   rts
+   adc     ($12,x)
+   .byte   $62         ; jam
+   rra     ($12,x)
+   .byte   $64,$12     ; nop     $12
+   adc     $12
+   ror     $12
+   rra     $12
+   pla
+   adc     #$12
+   ror     a
+   arr     #$12
+   jmp     ($3456)
+   adc     $3456
+   ror     $3456
+   rra     $3456
+   bvs     *+122
+   adc     ($12),y
+   .byte   $72         ; jam
+   rra     ($12),y
+   .byte   $74,$12     ; nop     $12,x
+   adc     $12,x
+   ror     $12,x
+   rra     $12,x
+   sei
+   adc     $3456,y
+   .byte   $7a         ; nop
+   rra     $3456,y
+   .byte   $7c,$56,$34 ; nop     $3456,x
+   adc     $3456,x
+   ror     $3456,x
+   rra     $3456,x
+   nop     #$12
+   sta     ($12,x)
+   .byte   $82,$12     ; nop     #$12
+   sax     ($12,x)
+   sty     $12
+   sta     $12
+   stx     $12
+   sax     $12
+   dey
+   .byte   $89,$12     ; nop     #$12
+   txa
+   .byte   $8b,$12     ; xaa     #$12
+   sty     $3456
+   sta     $3456
+   stx     $3456
+   sax     $3456
+   bcc     *+122
+   sta     ($12),y
+   .byte   $92     ; jam
+   .byte   $93,$12 ; ahx     ($12),y
+   sty     $12,x
+   sta     $12,x
+   stx     $12,y
+   sax     $12,y
+   tya
+   sta     $3456,y
+   txs
+   tas     $3456,y
+   shy     $3456,x
+   sta     $3456,x
+   shx     $3456,y
+   .byte   $9f,$56,$34 ;  ahx     $3456,y
+   ldy     #$12
+   lda     ($12,x)
+   ldx     #$12
+   lax     ($12,x)
+   ldy     $12
+   lda     $12
+   ldx     $12
+   lax     $12
+   tay
+   lda     #$12
+   tax
+   lax     #$12
+   ldy     $3456
+   lda     $3456
+   ldx     $3456
+   lax     $3456
+   bcs     *+122
+   lda     ($12),y
+   .byte   $b2     ; jam
+   lax     ($12),y
+   ldy     $12,x
+   lda     $12,x
+   ldx     $12,y
+   lax     $12,y
+   clv
+   lda     $3456,y
+   tsx
+   las     $3456,y
+   ldy     $3456,x
+   lda     $3456,x
+   ldx     $3456,y
+   lax     $3456,y
+   cpy     #$12
+   cmp     ($12,x)
+   .byte   $c2,$12     ; nop     #$12
+   dcp     ($12,x)
+   cpy     $12
+   cmp     $12
+   dec     $12
+   dcp     $12
+   iny
+   cmp     #$12
+   dex
+   axs     #$12
+   cpy     $3456
+   cmp     $3456
+   dec     $3456
+   dcp     $3456
+   bne     *+122
+   cmp     ($12),y
+   .byte   $d2         ; jam
+   dcp     ($12),y
+   .byte   $d4,$12     ; nop     $12,x
+   cmp     $12,x
+   dec     $12,x
+   dcp     $12,x
+   cld
+   cmp     $3456,y
+   .byte   $da         ; nop
+   dcp     $3456,y
+   .byte   $dc,$56,$34 ; nop     $3456,x
+   cmp     $3456,x
+   dec     $3456,x
+   dcp     $3456,x
+   cpx     #$12
+   sbc     ($12,x)
+   .byte   $e2,$12     ; nop     #$12
+   isc     ($12,x)
+   cpx     $12
+   sbc     $12
+   inc     $12
+   isc     $12
+   inx
+   sbc     #$12
+   nop
+   .byte   $eb         ; nop
+   cpx     $3456
+   sbc     $3456
+   inc     $3456
+   isc     $3456
+   beq     *+122
+   sbc     ($12),y
+   .byte   $f2         ; jam
+   isc     ($12),y
+   .byte   $f4,$12     ; nop     $12,x
+   sbc     $12,x
+   inc     $12,x
+   isc     $12,x
+   sed
+   sbc     $3456,y
+   .byte   $fa         ; nop
+   isc     $3456,y
+   .byte   $fc,$56,$34 ; nop     $3456,x
+   sbc     $3456,x
+   inc     $3456,x
+   isc     $3456,x
diff --git a/test/asm/65816-cpudetect.ref b/test/asm/65816-cpudetect.ref
new file mode 100644 (file)
index 0000000..4f6e767
Binary files /dev/null and b/test/asm/65816-cpudetect.ref differ
diff --git a/test/asm/65c02-cpudetect.ref b/test/asm/65c02-cpudetect.ref
new file mode 100644 (file)
index 0000000..9f790d5
Binary files /dev/null and b/test/asm/65c02-cpudetect.ref differ
diff --git a/test/asm/65c02-opcodes.ref b/test/asm/65c02-opcodes.ref
new file mode 100644 (file)
index 0000000..2d44045
Binary files /dev/null and b/test/asm/65c02-opcodes.ref differ
diff --git a/test/asm/65c02-opcodes.s b/test/asm/65c02-opcodes.s
new file mode 100644 (file)
index 0000000..09c3f04
--- /dev/null
@@ -0,0 +1,258 @@
+.setcpu "65C02"
+
+   brk
+   ora     ($12,x)
+   .byte   $02
+   .byte   $03
+   tsb     $12
+   ora     $12
+   asl     $12
+   rmb0    $12
+   php
+   ora     #$12
+   asl     a
+   .byte   $0B
+   tsb     $3456
+   ora     $3456
+   asl     $3456
+   bbr0    $12,*+122
+   bpl     *+122
+   ora     ($12),y
+   ora     ($12)
+   .byte   $13
+   trb     $12
+   ora     $12,x
+   asl     $12,x
+   rmb1    $12
+   clc
+   ora     $3456,y
+   inc     a
+   .byte   $1B
+   trb     $3456
+   ora     $3456,x
+   asl     $3456,x
+   bbr1    $12,*+122
+   jsr     $3456
+   and     ($12,x)
+   .byte   $22
+   .byte   $23
+   bit     $12
+   and     $12
+   rol     $12
+   rmb2    $12
+   plp
+   and     #$12
+   rol     a
+   .byte   $2B
+   bit     $3456
+   and     $3456
+   rol     $3456
+   bbr2    $12,*+122
+   bmi     *+122
+   and     ($12),y
+   and     ($12)
+   .byte   $33
+   bit     $12,x
+   and     $12,x
+   rol     $12,x
+   rmb3    $12
+   sec
+   and     $3456,y
+   dec     a
+   .byte   $3B
+   bit     $3456,x
+   and     $3456,x
+   rol     $3456,x
+   bbr3    $12,*+122
+   rti
+   eor     ($12,x)
+   .byte   $42
+   .byte   $43
+   .byte   $44
+   eor     $12
+   lsr     $12
+   rmb4    $12
+   pha
+   eor     #$12
+   lsr     a
+   .byte   $4B
+   jmp     $3456
+   eor     $3456
+   lsr     $3456
+   bbr4    $12,*+122
+   bvc     *+122
+   eor     ($12),y
+   eor     ($12)
+   .byte   $53
+   .byte   $54
+   eor     $12,x
+   lsr     $12,x
+   rmb5    $12
+   cli
+   eor     $3456,y
+   phy
+   .byte   $5B
+   .byte   $5C
+   eor     $3456,x
+   lsr     $3456,x
+   bbr5    $12,*+122
+   rts
+   adc     ($12,x)
+   .byte   $62
+   .byte   $63
+   stz     $12
+   adc     $12
+   ror     $12
+   rmb6    $12
+   pla
+   adc     #$12
+   ror     a
+   .byte   $6B
+   jmp     ($3456)
+   adc     $3456
+   ror     $3456
+   bbr6    $12,*+122
+   bvs     *+122
+   adc     ($12),y
+   adc     ($12)
+   .byte   $73
+   stz     $12,x
+   adc     $12,x
+   ror     $12,x
+   rmb7    $12
+   sei
+   adc     $3456,y
+   ply
+   .byte   $7B
+   jmp     ($3456,x)
+   adc     $3456,x
+   ror     $3456,x
+   bbr7    $12,*+122
+   bra     *+122
+   sta     ($12,x)
+   .byte   $82
+   .byte   $83
+   sty     $12
+   sta     $12
+   stx     $12
+   smb0    $12
+   dey
+   bit     #$12
+   txa
+   .byte   $8B
+   sty     $3456
+   sta     $3456
+   stx     $3456
+   bbs0    $12,*+122
+   bcc     *+122
+   sta     ($12),y
+   sta     ($12)
+   .byte   $93
+   sty     $12,x
+   sta     $12,x
+   stx     $12,y
+   smb1    $12
+   tya
+   sta     $3456,y
+   txs
+   .byte   $9B
+   stz     $3456
+   sta     $3456,x
+   stz     $3456,x
+   bbs1    $12,*+122
+   ldy     #$12
+   lda     ($12,x)
+   ldx     #$12
+   .byte   $A3
+   ldy     $12
+   lda     $12
+   ldx     $12
+   smb2    $12
+   tay
+   lda     #$12
+   tax
+   .byte   $AB
+   ldy     $3456
+   lda     $3456
+   ldx     $3456
+   bbs2    $12,*+122
+   bcs     *+122
+   lda     ($12),y
+   lda     ($12)
+   .byte   $B3
+   ldy     $12,x
+   lda     $12,x
+   ldx     $12,y
+   smb3    $12
+   clv
+   lda     $3456,y
+   tsx
+   .byte   $BB
+   ldy     $3456,x
+   lda     $3456,x
+   ldx     $3456,y
+   bbs3    $12,*+122
+   cpy     #$12
+   cmp     ($12,x)
+   .byte   $C2
+   .byte   $C3
+   cpy     $12
+   cmp     $12
+   dec     $12
+   smb4    $12
+   iny
+   cmp     #$12
+   dex
+   .byte   $CB
+   cpy     $3456
+   cmp     $3456
+   dec     $3456
+   bbs4    $12,*+122
+   bne     *+122
+   cmp     ($12),y
+   cmp     ($12)
+   .byte   $D3
+   .byte   $D4
+   cmp     $12,x
+   dec     $12,x
+   smb5    $12
+   cld
+   cmp     $3456,y
+   phx
+   .byte   $DB
+   .byte   $DC
+   cmp     $3456,x
+   dec     $3456,x
+   bbs5    $12,*+122
+   cpx     #$12
+   sbc     ($12,x)
+   .byte   $E2
+   .byte   $E3
+   cpx     $12
+   sbc     $12
+   inc     $12
+   smb6    $12
+   inx
+   sbc     #$12
+   nop
+   .byte   $EB
+   cpx     $3456
+   sbc     $3456
+   inc     $3456
+   bbs6    $12,*+122
+   beq     *+122
+   sbc     ($12),y
+   sbc     ($12)
+   .byte   $F3
+   .byte   $F4
+   sbc     $12,x
+   inc     $12,x
+   smb7    $12
+   sed
+   sbc     $3456,y
+   plx
+   .byte   $FB
+   .byte   $FC
+   sbc     $3456,x
+   inc     $3456,x
+   bbs7    $12,*+122
diff --git a/test/asm/65sc02-cpudetect.ref b/test/asm/65sc02-cpudetect.ref
new file mode 100644 (file)
index 0000000..4e11bd7
Binary files /dev/null and b/test/asm/65sc02-cpudetect.ref differ
diff --git a/test/asm/65sc02-opcodes.ref b/test/asm/65sc02-opcodes.ref
new file mode 100644 (file)
index 0000000..d22fe66
Binary files /dev/null and b/test/asm/65sc02-opcodes.ref differ
diff --git a/test/asm/65sc02-opcodes.s b/test/asm/65sc02-opcodes.s
new file mode 100644 (file)
index 0000000..aa53991
--- /dev/null
@@ -0,0 +1,258 @@
+.setcpu "65SC02"
+
+   brk
+   ora     ($12,x)
+   .byte   $02
+   .byte   $03
+   tsb     $12
+   ora     $12
+   asl     $12
+   .byte   $07
+   php
+   ora     #$12
+   asl     a
+   .byte   $0B
+   tsb     $3456
+   ora     $3456
+   asl     $3456
+   .byte   $0F
+   bpl     *+122
+   ora     ($12),y
+   ora     ($12)
+   .byte   $13
+   trb     $12
+   ora     $12,x
+   asl     $12,x
+   .byte   $17
+   clc
+   ora     $3456,y
+   inc     a
+   .byte   $1B
+   trb     $3456
+   ora     $3456,x
+   asl     $3456,x
+   .byte   $1F
+   jsr     $3456
+   and     ($12,x)
+   .byte   $22
+   .byte   $23
+   bit     $12
+   and     $12
+   rol     $12
+   .byte   $27
+   plp
+   and     #$12
+   rol     a
+   .byte   $2B
+   bit     $3456
+   and     $3456
+   rol     $3456
+   .byte   $2F
+   bmi     *+122
+   and     ($12),y
+   and     ($12)
+   .byte   $33
+   bit     $12,x
+   and     $12,x
+   rol     $12,x
+   .byte   $37
+   sec
+   and     $3456,y
+   dec     a
+   .byte   $3B
+   bit     $3456,x
+   and     $3456,x
+   rol     $3456,x
+   .byte   $3F
+   rti
+   eor     ($12,x)
+   .byte   $42
+   .byte   $43
+   .byte   $44
+   eor     $12
+   lsr     $12
+   .byte   $47
+   pha
+   eor     #$12
+   lsr     a
+   .byte   $4B
+   jmp     $3456
+   eor     $3456
+   lsr     $3456
+   .byte   $4F
+   bvc     *+122
+   eor     ($12),y
+   eor     ($12)
+   .byte   $53
+   .byte   $54
+   eor     $12,x
+   lsr     $12,x
+   .byte   $57
+   cli
+   eor     $3456,y
+   phy
+   .byte   $5B
+   .byte   $5C
+   eor     $3456,x
+   lsr     $3456,x
+   .byte   $5F
+   rts
+   adc     ($12,x)
+   .byte   $62
+   .byte   $63
+   stz     $12
+   adc     $12
+   ror     $12
+   .byte   $67
+   pla
+   adc     #$12
+   ror     a
+   .byte   $6B
+   jmp     ($3456)
+   adc     $3456
+   ror     $3456
+   .byte   $6F
+   bvs     *+122
+   adc     ($12),y
+   adc     ($12)
+   .byte   $73
+   stz     $12,x
+   adc     $12,x
+   ror     $12,x
+   .byte   $77
+   sei
+   adc     $3456,y
+   ply
+   .byte   $7B
+   jmp     ($3456,x)
+   adc     $3456,x
+   ror     $3456,x
+   .byte   $7F
+   bra     *+122
+   sta     ($12,x)
+   .byte   $82
+   .byte   $83
+   sty     $12
+   sta     $12
+   stx     $12
+   .byte   $87
+   dey
+   bit     #$12
+   txa
+   .byte   $8B
+   sty     $3456
+   sta     $3456
+   stx     $3456
+   .byte   $8F
+   bcc     *+122
+   sta     ($12),y
+   sta     ($12)
+   .byte   $93
+   sty     $12,x
+   sta     $12,x
+   stx     $12,y
+   .byte   $97
+   tya
+   sta     $3456,y
+   txs
+   .byte   $9B
+   stz     $3456
+   sta     $3456,x
+   stz     $3456,x
+   .byte   $9F
+   ldy     #$12
+   lda     ($12,x)
+   ldx     #$12
+   .byte   $A3
+   ldy     $12
+   lda     $12
+   ldx     $12
+   .byte   $A7
+   tay
+   lda     #$12
+   tax
+   .byte   $AB
+   ldy     $3456
+   lda     $3456
+   ldx     $3456
+   .byte   $AF
+   bcs     *+122
+   lda     ($12),y
+   lda     ($12)
+   .byte   $B3
+   ldy     $12,x
+   lda     $12,x
+   ldx     $12,y
+   .byte   $B7
+   clv
+   lda     $3456,y
+   tsx
+   .byte   $BB
+   ldy     $3456,x
+   lda     $3456,x
+   ldx     $3456,y
+   .byte   $BF
+   cpy     #$12
+   cmp     ($12,x)
+   .byte   $C2
+   .byte   $C3
+   cpy     $12
+   cmp     $12
+   dec     $12
+   .byte   $C7
+   iny
+   cmp     #$12
+   dex
+   .byte   $CB
+   cpy     $3456
+   cmp     $3456
+   dec     $3456
+   .byte   $CF
+   bne     *+122
+   cmp     ($12),y
+   cmp     ($12)
+   .byte   $D3
+   .byte   $D4
+   cmp     $12,x
+   dec     $12,x
+   .byte   $D7
+   cld
+   cmp     $3456,y
+   phx
+   .byte   $DB
+   .byte   $DC
+   cmp     $3456,x
+   dec     $3456,x
+   .byte   $DF
+   cpx     #$12
+   sbc     ($12,x)
+   .byte   $E2
+   .byte   $E3
+   cpx     $12
+   sbc     $12
+   inc     $12
+   .byte   $E7
+   inx
+   sbc     #$12
+   nop
+   .byte   $EB
+   cpx     $3456
+   sbc     $3456
+   inc     $3456
+   .byte   $EF
+   beq     *+122
+   sbc     ($12),y
+   sbc     ($12)
+   .byte   $F3
+   .byte   $F4
+   sbc     $12,x
+   inc     $12,x
+   .byte   $F7
+   sed
+   sbc     $3456,y
+   plx
+   .byte   $FB
+   .byte   $FC
+   sbc     $3456,x
+   inc     $3456,x
+   .byte   $FF
diff --git a/test/asm/Makefile b/test/asm/Makefile
new file mode 100644 (file)
index 0000000..93210aa
--- /dev/null
@@ -0,0 +1,74 @@
+# Makefile for the assembler regression tests
+
+ifneq ($(shell echo),)
+  CMD_EXE = 1
+endif
+
+ifdef CMD_EXE
+  EXE = .exe
+  MKDIR = mkdir $(subst /,\,$1)
+  RMDIR = -rmdir /s /q $(subst /,\,$1)
+  DEL = del /f $(subst /,\,$1)
+else
+  EXE =
+  MKDIR = mkdir -p $1
+  RMDIR = $(RM) -r $1
+  DEL = $(RM) $1
+endif
+
+ifdef QUIET
+  .SILENT:
+endif
+
+CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
+
+WORKDIR = ../../testwrk/asm
+
+DIFF = $(WORKDIR)/bdiff$(EXE)
+
+CC = gcc
+CFLAGS = -O2
+
+.PHONY: all clean
+
+OPCODE_REFS := $(wildcard *-opcodes.ref)
+OPCODE_CPUS = $(foreach ref,$(OPCODE_REFS),$(ref:%-opcodes.ref=%))
+OPCODE_BINS = $(foreach cpu,$(OPCODE_CPUS),$(WORKDIR)/$(cpu)-opcodes.bin)
+
+CPUDETECT_REFS := $(wildcard *-cpudetect.ref)
+CPUDETECT_CPUS = $(foreach ref,$(CPUDETECT_REFS),$(ref:%-cpudetect.ref=%))
+CPUDETECT_BINS = $(foreach cpu,$(CPUDETECT_CPUS),$(WORKDIR)/$(cpu)-cpudetect.bin)
+
+all: $(OPCODE_BINS) $(CPUDETECT_BINS)
+
+$(WORKDIR):
+       $(call MKDIR,$(WORKDIR))
+
+$(DIFF): ../bdiff.c | $(WORKDIR)
+       $(CC) $(CFLAGS) -o $@ $<
+
+define OPCODE_template
+
+$(WORKDIR)/$1-opcodes.bin: $1-opcodes.s $(DIFF)
+       $(if $(QUIET),echo asm/$1-opcodes.bin)
+       $(CL65) --cpu $1 -t none -l $(WORKDIR)/$1-opcodes.lst -o $$@ $$<
+       $(DIFF) $$@ $1-opcodes.ref
+
+endef # OPCODE_template
+
+$(foreach cpu,$(OPCODE_CPUS),$(eval $(call OPCODE_template,$(cpu))))
+
+define CPUDETECT_template
+
+$(WORKDIR)/$1-cpudetect.bin: cpudetect.s $(DIFF)
+       $(if $(QUIET),echo asm/$1-cpudetect.bin)
+       $(CL65) --cpu $1 -t none -l $(WORKDIR)/$1-cpudetect.lst -o $$@ $$<
+       $(DIFF) $$@ $1-cpudetect.ref
+
+endef # CPUDETECT_template
+
+$(foreach cpu,$(CPUDETECT_CPUS),$(eval $(call CPUDETECT_template,$(cpu))))
+
+clean:
+       @$(call RMDIR,$(WORKDIR))
+       @$(call DEL,$(OPCODE_REFS:.ref=.o) cpudetect.o)
diff --git a/test/asm/README b/test/asm/README
new file mode 100644 (file)
index 0000000..a2b1e9a
--- /dev/null
@@ -0,0 +1,48 @@
+
+Assembler Testcases
+===================
+
+Opcode Tests:
+-------------
+
+These testcases are inspired by the ones now removed from test/assembler.
+The main purpose is to have each possible opcode generated at least once,
+either by an assembly instruction or a ".byte"-placeholder. Typically
+generated by disassembling a binary dump that contains data in the form
+of the pattern that each opcode is stated once in order followed by easy
+to recognise:
+
+00 00 EA 00
+01 00 EA 00
+02 00 EA 00
+[...]
+fe 00 EA 00
+ff 00 EA 00
+
+The disassembly is then put in a better readable form by replacing the
+leftover dummy opcode parameters with something more recognizable.
+
+The testcases for 6502, 6502x, 65sc02, 65c02, 4510, and huc6280 have been
+put together by Sven Oliver ("SvOlli") Moll, as well as a template for the
+m740 instructions set.
+
+Still to do is to find a way to implement an opcode testcase for the 65816
+processor, since it's capable of executing instructions with an 8-bit and
+a 16-bit operator alike, only distinguished by one processor flag.
+
+
+CPU detect Tests
+----------------
+
+These tests all assemble the same file "cpudetect.s" which contains several
+conditionals for several CPUs, only using every option known to the "--cpu"
+commandline switch of ca65/cl65.
+
+
+Reference (".ref") Files
+------------------------
+
+A hint on creating these files: when running the test, it will fail due to
+the missing ".ref" file. Review the output of the ".lst" very pedantic, then
+copy the ".bin" to the ".ref" file.
+
diff --git a/test/asm/cpudetect.s b/test/asm/cpudetect.s
new file mode 100644 (file)
index 0000000..adad7c1
--- /dev/null
@@ -0,0 +1,66 @@
+
+.macpack cpu
+
+; step 1: try to assemble an instruction that's exclusive to this set
+;         (when possible)
+
+.ifp02
+   lda #$ea
+.endif
+
+.ifpsc02
+   jmp ($1234,x)
+.endif
+
+.ifpc02
+   rmb0 $12
+.endif
+
+.ifp816
+   xba
+.endif
+
+.ifp4510
+   taz
+.endif
+
+
+; step 2: check for bitwise compatibility of instructions sets
+;         (made verbose for better reading with hexdump/hd(1))
+
+.if (.cpu .bitand CPU_ISET_NONE)
+   .byte 0,"CPU_ISET_NONE"
+.endif
+
+.if (.cpu .bitand CPU_ISET_6502)
+   .byte 0,"CPU_ISET_6502"
+.endif
+
+.if (.cpu .bitand CPU_ISET_6502X)
+   .byte 0,"CPU_ISET_6502X"
+.endif
+
+.if (.cpu .bitand CPU_ISET_65SC02)
+   .byte 0,"CPU_ISET_65SC02"
+.endif
+
+.if (.cpu .bitand CPU_ISET_65C02)
+   .byte 0,"CPU_ISET_65C02"
+.endif
+
+.if (.cpu .bitand CPU_ISET_65816)
+   .byte 0,"CPU_ISET_65816"
+.endif
+
+.if (.cpu .bitand CPU_ISET_SWEET16)
+   .byte 0,"CPU_ISET_SWEET16"
+.endif
+
+.if (.cpu .bitand CPU_ISET_HUC6280)
+   .byte 0,"CPU_ISET_HUC6280"
+.endif
+
+.if (.cpu .bitand CPU_ISET_4510)
+   .byte 0,"CPU_ISET_4510"
+.endif
+
diff --git a/test/asm/huc6280-cpudetect.ref b/test/asm/huc6280-cpudetect.ref
new file mode 100644 (file)
index 0000000..646e0f4
Binary files /dev/null and b/test/asm/huc6280-cpudetect.ref differ
diff --git a/test/asm/huc6280-opcodes.ref b/test/asm/huc6280-opcodes.ref
new file mode 100644 (file)
index 0000000..33f5b29
Binary files /dev/null and b/test/asm/huc6280-opcodes.ref differ
diff --git a/test/asm/huc6280-opcodes.s b/test/asm/huc6280-opcodes.s
new file mode 100644 (file)
index 0000000..bd3ad5c
--- /dev/null
@@ -0,0 +1,258 @@
+.setcpu "huc6280"
+
+   brk
+   ora     ($12,x)
+   sxy
+   st0     #$12
+   tsb     $12
+   ora     $12
+   asl     $12
+   rmb0    $12
+   php
+   ora     #$12
+   asl     a
+   .byte   $0B
+   tsb     $3456
+   ora     $3456
+   asl     $3456
+   bbr0    $12,*+122
+   bpl     *+122
+   ora     ($12),y
+   ora     ($12)
+   st1     #$12
+   trb     $12
+   ora     $12,x
+   asl     $12,x
+   rmb1    $12
+   clc
+   ora     $3456,y
+   inc     a
+   .byte   $1B
+   trb     $3456
+   ora     $3456,x
+   asl     $3456,x
+   bbr1    $12,*+122
+   jsr     $3456
+   and     ($12,x)
+   sax
+   st2     #$12
+   bit     $12
+   and     $12
+   rol     $12
+   rmb2    $12
+   plp
+   and     #$12
+   rol     a
+   .byte   $2B
+   bit     $3456
+   and     $3456
+   rol     $3456
+   bbr2    $12,*+122
+   bmi     *+122
+   and     ($12),y
+   and     ($12)
+   .byte   $33
+   bit     $12,x
+   and     $12,x
+   rol     $12,x
+   rmb3    $12
+   sec
+   and     $3456,y
+   dec     a
+   .byte   $3B
+   bit     $3456,x
+   and     $3456,x
+   rol     $3456,x
+   bbr3    $12,*+122
+   rti
+   eor     ($12,x)
+   say
+   tma     #$02
+   bsr     *+122
+   eor     $12
+   lsr     $12
+   rmb4    $12
+   pha
+   eor     #$12
+   lsr     a
+   .byte   $4B
+   jmp     $3456
+   eor     $3456
+   lsr     $3456
+   bbr4    $12,*+122
+   bvc     *+122
+   eor     ($12),y
+   eor     ($12)
+   tam     #$12
+   csl
+   eor     $12,x
+   lsr     $12,x
+   rmb5    $12
+   cli
+   eor     $3456,y
+   phy
+   .byte   $5B
+   .byte   $5C
+   eor     $3456,x
+   lsr     $3456,x
+   bbr5    $12,*+122
+   rts
+   adc     ($12,x)
+   cla
+   .byte   $63
+   stz     $12
+   adc     $12
+   ror     $12
+   rmb6    $12
+   pla
+   adc     #$12
+   ror     a
+   .byte   $6B
+   jmp     ($3456)
+   adc     $3456
+   ror     $3456
+   bbr6    $12,*+122
+   bvs     *+122
+   adc     ($12),y
+   adc     ($12)
+   tii     $3333,$7373,$1111
+   stz     $12,x
+   adc     $12,x
+   ror     $12,x
+   rmb7    $12
+   sei
+   adc     $3456,y
+   ply
+   .byte   $7B
+   jmp     ($3456,x)
+   adc     $3456,x
+   ror     $3456,x
+   bbr7    $12,*+122
+   bra     *+122
+   sta     ($12,x)
+   clx
+   tst     #$12,$EA
+   sty     $12
+   sta     $12
+   stx     $12
+   smb0    $12
+   dey
+   bit     #$12
+   txa
+   .byte   $8B
+   sty     $3456
+   sta     $3456
+   stx     $3456
+   bbs0    $12,*+122
+   bcc     *+122
+   sta     ($12),y
+   sta     ($12)
+   tst     #$12,$EAEA
+   sty     $12,x
+   sta     $12,x
+   stx     $12,y
+   smb1    $12
+   tya
+   sta     $3456,y
+   txs
+   .byte   $9B
+   stz     $3456
+   sta     $3456,x
+   stz     $3456,x
+   bbs1    $12,*+122
+   ldy     #$12
+   lda     ($12,x)
+   ldx     #$12
+   tst     #$12,$EA,x
+   ldy     $12
+   lda     $12
+   ldx     $12
+   smb2    $12
+   tay
+   lda     #$12
+   tax
+   .byte   $AB
+   ldy     $3456
+   lda     $3456
+   ldx     $3456
+   bbs2    $12,*+122
+   bcs     *+122
+   lda     ($12),y
+   lda     ($12)
+   tst     #$12,$EAEA,x
+   ldy     $12,x
+   lda     $12,x
+   ldx     $12,y
+   smb3    $12
+   clv
+   lda     $3456,y
+   tsx
+   .byte   $BB
+   ldy     $3456,x
+   lda     $3456,x
+   ldx     $3456,y
+   bbs3    $12,*+122
+   cpy     #$12
+   cmp     ($12,x)
+   cly
+   tdd     $3333,$C3C3,$1111
+   cpy     $12
+   cmp     $12
+   dec     $12
+   smb4    $12
+   iny
+   cmp     #$12
+   dex
+   .byte   $CB
+   cpy     $3456
+   cmp     $3456
+   dec     $3456
+   bbs4    $12,*+122
+   bne     *+122
+   cmp     ($12),y
+   cmp     ($12)
+   tin     $3333,$D3D3,$1111
+   .byte   $D4
+   cmp     $12,x
+   dec     $12,x
+   smb5    $12
+   cld
+   cmp     $3456,y
+   phx
+   .byte   $DB
+   .byte   $DC
+   cmp     $3456,x
+   dec     $3456,x
+   bbs5    $12,*+122
+   cpx     #$12
+   sbc     ($12,x)
+   .byte   $E2
+   tia     $3333,$E3E3,$1111
+   cpx     $12
+   sbc     $12
+   inc     $12
+   smb6    $12
+   inx
+   sbc     #$12
+   nop
+   .byte   $EB
+   cpx     $3456
+   sbc     $3456
+   inc     $3456
+   bbs6    $12,*+122
+   beq     *+122
+   sbc     ($12),y
+   sbc     ($12)
+   tai     $3333,$F3F3,$1111
+   .byte   $F4
+   sbc     $12,x
+   inc     $12,x
+   smb7    $12
+   sed
+   sbc     $3456,y
+   plx
+   .byte   $FB
+   .byte   $FC
+   sbc     $3456,x
+   inc     $3456,x
+   bbs7    $12,*+122
diff --git a/test/asm/m740-opcodes.s b/test/asm/m740-opcodes.s
new file mode 100644 (file)
index 0000000..df6d714
--- /dev/null
@@ -0,0 +1,260 @@
+.setcpu "65C02"
+; copy of 65c02, comments note changes to the m740 according to
+; http://documentation.renesas.com/doc/products/mpumcu/rej09b0322_740sm.pdf
+
+   brk
+   ora     ($12,x)
+   .byte   $02,$00,$00 ; jsr zp,ind
+   .byte   $03,$00,$00 ; bbs 0,a
+   tsb     $12         ; .byte $04
+   ora     $12
+   asl     $12
+   rmb0    $12         ; bbs 0,zp
+   php
+   ora     #$12
+   asl     a
+   .byte   $0B,$00,$00 ; seb 0,a
+   tsb     $3456       ; .byte $0c
+   ora     $3456
+   asl     $3456
+   bbr0    $12,*+122   ; seb 0,zp
+   bpl     *+122
+   ora     ($12),y
+   ora     ($12)       ; clt
+   .byte   $13,$00,$00 ; bbc 0,a
+   trb     $12         ; .byte $14
+   ora     $12,x
+   asl     $12,x
+   rmb1    $12         ; bbc 0,zp
+   clc
+   ora     $3456,y
+   inc     a
+   .byte   $1B,$00,$00 ; clb 0,a
+   trb     $3456       ; .byte $1c
+   ora     $3456,x
+   asl     $3456,x
+   bbr1    $12,*+122   ; clb 0,zp
+   jsr     $3456
+   and     ($12,x)
+   .byte   $22,$00,$00 ; jsr sp
+   .byte   $23,$00,$00 ; bbs 1,a
+   bit     $12
+   and     $12
+   rol     $12
+   rmb2    $12         ; bbs 1,zp
+   plp
+   and     #$12
+   rol     a
+   .byte   $2B,$00,$00 ; seb 1,a
+   bit     $3456
+   and     $3456
+   rol     $3456
+   bbr2    $12,*+122   ; seb 1,zp
+   bmi     *+122
+   and     ($12),y
+   and     ($12)       ; set
+   .byte   $33,$00,$00 ; bbc 1,a
+   bit     $12,x       ; .byte $34
+   and     $12,x
+   rol     $12,x
+   rmb3    $12         ; bbc 1,zp
+   sec
+   and     $3456,y
+   dec     a
+   .byte   $3B,$00,$00 ; clb 1,a
+   bit     $3456,x     ; ldm zp
+   and     $3456,x
+   rol     $3456,x
+   bbr3    $12,*+122   ; clb 1,zp
+   rti
+   eor     ($12,x)
+   .byte   $42,$00,$00 ; stp
+   .byte   $43,$00,$00 ; bbs 2,a
+   .byte   $44,$00,$00 ; com zp
+   eor     $12
+   lsr     $12
+   rmb4    $12         ; bbs 2,zp
+   pha
+   eor     #$12
+   lsr     a
+   .byte   $4B,$00,$00 ; seb 2,a
+   jmp     $3456
+   eor     $3456
+   lsr     $3456
+   bbr4    $12,*+122   ; seb 2,zp
+   bvc     *+122
+   eor     ($12),y
+   eor     ($12)       ; .byte $52
+   .byte   $53,$00,$00 ; bbc 2,a
+   .byte   $54,$00,$00
+   eor     $12,x
+   lsr     $12,x
+   rmb5    $12         ; bbc 2,zp
+   cli
+   eor     $3456,y
+   phy
+   .byte   $5B,$00,$00 ; clb 2,a
+   .byte   $5C,$00,$00
+   eor     $3456,x
+   lsr     $3456,x
+   bbr5    $12,*+122   ; clb 2,zp
+   rts
+   adc     ($12,x)
+   .byte   $62,$00,$00 ; mul zp,x
+   .byte   $63,$00,$00 ; bbs 3,a
+   stz     $12         ; tst zp
+   adc     $12
+   ror     $12
+   rmb6    $12         ; bbs 3,zp
+   pla
+   adc     #$12
+   ror     a
+   .byte   $6B,$00,$00 ; seb 3,a
+   jmp     ($3456)
+   adc     $3456
+   ror     $3456
+   bbr6    $12,*+122   ; seb 3,zp
+   bvs     *+122
+   adc     ($12),y
+   adc     ($12)       ; .byte $72
+   .byte   $73,$00,$00 ; bbc 3,a
+   stz     $12,x       ; .byte $74
+   adc     $12,x
+   ror     $12,x
+   rmb7    $12         ; bbc 3,zp
+   sei
+   adc     $3456,y
+   ply
+   .byte   $7B,$00,$00 ; clb 3,a
+   jmp     ($3456,x)   ; .byte $7c
+   adc     $3456,x
+   ror     $3456,x
+   bbr7    $12,*+122   ; clb 3,zp
+   bra     *+122
+   sta     ($12,x)
+   .byte   $82,$00,$00 ; rrf zp
+   .byte   $83,$00,$00 ; bbs 4,a
+   sty     $12
+   sta     $12
+   stx     $12
+   smb0    $12         ; bbs 4,zp
+   dey
+   bit     #$12
+   txa
+   .byte   $8B,$00,$00 ; seb 4,a
+   sty     $3456
+   sta     $3456
+   stx     $3456
+   bbs0    $12,*+122   ; seb 4,zp
+   bcc     *+122
+   sta     ($12),y
+   sta     ($12)       ; .byte $92
+   .byte   $93,$00,$00 ; bbc 4,a
+   sty     $12,x
+   sta     $12,x
+   stx     $12,y
+   smb1    $12         ; bbc 4,zp
+   tya
+   sta     $3456,y
+   txs
+   .byte   $9B,$00,$00 ; clb 4,a
+   stz     $3456       ; .byte $9c
+   sta     $3456,x
+   stz     $3456,x     ; .byte $9e
+   bbs1    $12,*+122   ; clb 4,zp
+   ldy     #$12
+   lda     ($12,x)
+   ldx     #$12
+   .byte   $A3,$00,$00 ; bbs 5,a
+   ldy     $12
+   lda     $12
+   ldx     $12
+   smb2    $12         ; bbs 5,zp
+   tay
+   lda     #$12
+   tax
+   .byte   $AB,$00,$00 ; seb 5,a
+   ldy     $3456
+   lda     $3456
+   ldx     $3456
+   bbs2    $12,*+122   ; seb 5,zp
+   bcs     *+122
+   lda     ($12),y
+   lda     ($12)       ; .byte $b2
+   .byte   $B3,$00,$00 ; bbc 5,a
+   ldy     $12,x
+   lda     $12,x
+   ldx     $12,y
+   smb3    $12         ; bbc 5,zp
+   clv
+   lda     $3456,y
+   tsx
+   .byte   $BB,$00,$00 ; clb 5,a
+   ldy     $3456,x
+   lda     $3456,x
+   ldx     $3456,y
+   bbs3    $12,*+122   ; clb 5,zp
+   cpy     #$12
+   cmp     ($12,x)
+   .byte   $C2,$00,$00 ; wit
+   .byte   $C3,$00,$00 ; bbs 6,a
+   cpy     $12
+   cmp     $12
+   dec     $12
+   smb4    $12         ; bbs 6,zp
+   iny
+   cmp     #$12
+   dex
+   .byte   $CB,$00,$00 ; seb 6,a
+   cpy     $3456
+   cmp     $3456
+   dec     $3456
+   bbs4    $12,*+122   ; seb 6,zp
+   bne     *+122
+   cmp     ($12),y
+   cmp     ($12)       ; .byte $d2
+   .byte   $D3,$00,$00 ; bbc 6,a
+   .byte   $D4,$00,$00
+   cmp     $12,x
+   dec     $12,x
+   smb5    $12         ; bbc 6,zp
+   cld
+   cmp     $3456,y
+   phx
+   .byte   $DB,$00,$00 ; clb 6,a
+   .byte   $DC,$00,$00
+   cmp     $3456,x
+   dec     $3456,x
+   bbs5    $12,*+122   ; clb 6,zp
+   cpx     #$12
+   sbc     ($12,x)
+   .byte   $E2,$00,$00 ; div zp,x
+   .byte   $E3,$00,$00 ; bbs 7,a
+   cpx     $12
+   sbc     $12
+   inc     $12
+   smb6    $12         ; bbs 7,zp
+   inx
+   sbc     #$12
+   nop
+   .byte   $EB,$00,$00 ; seb 7,a
+   cpx     $3456
+   sbc     $3456
+   inc     $3456
+   bbs6    $12,*+122   ; seb 7,zp
+   beq     *+122
+   sbc     ($12),y
+   sbc     ($12)       ; .byte $f2
+   .byte   $F3,$00,$00 ; bbc 7,a
+   .byte   $F4,$00,$00
+   sbc     $12,x
+   inc     $12,x
+   smb7    $12         ; bbc 7,zp
+   sed
+   sbc     $3456,y
+   plx
+   .byte   $FB,$00,$00 ; clb 7,a
+   .byte   $FC,$00,$00
+   sbc     $3456,x
+   inc     $3456,x
+   bbs7    $12,*+122   ; clb 7,zp
diff --git a/test/assembler/.gitignore b/test/assembler/.gitignore
deleted file mode 100644 (file)
index c0c74a3..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-*.o
-*.bin
-*.lst
diff --git a/test/assembler/4510-cpudetect.ref b/test/assembler/4510-cpudetect.ref
deleted file mode 100644 (file)
index 515557c..0000000
Binary files a/test/assembler/4510-cpudetect.ref and /dev/null differ
diff --git a/test/assembler/4510-opcodes.ref b/test/assembler/4510-opcodes.ref
deleted file mode 100644 (file)
index b65b12e..0000000
Binary files a/test/assembler/4510-opcodes.ref and /dev/null differ
diff --git a/test/assembler/4510-opcodes.s b/test/assembler/4510-opcodes.s
deleted file mode 100644 (file)
index 3d68056..0000000
+++ /dev/null
@@ -1,278 +0,0 @@
-.setcpu "4510"
-
-   brk
-   ora ($05,x)
-   cle
-   see
-   tsb $02
-   ora $02
-   asl $02
-   rmb0 $02
-   php
-   ora #$01
-   asl
-   tsy
-   tsb $1234
-   ora $1234
-   asl $1234
-   bbr0 $02,*+$34
-
-   bpl *+$32
-   ora ($06),y
-   ora ($07),z
-   lbpl *+$3133 ; bpl *+$3133
-   trb $02
-   ora $03,x
-   asl $03,x
-   rmb1 $02
-   clc
-   ora $1456,y
-   inc
-   inz
-   trb $1234
-   ora $1345,x
-   asl $1345,x
-   bbr1 $02,*+$34
-
-   jsr $1234
-   and ($05,x)
-   jsr ($2345)
-   jsr ($2456,x)
-   bit $02
-   and $02
-   rol $02
-   rmb2 $02
-   plp
-   and #$01
-   rol
-   tys
-   bit $1234
-   and $1234
-   rol $1234
-   bbr2 $02,*+$34
-
-   bmi *+$32
-   and ($06),y
-   and ($07),z
-   lbmi *+$3133 ; bmi *+$3133
-   bit $03,x
-   and $03,x
-   rol $03,x
-   rmb3 $02
-   sec
-   and $1456,y
-   dec
-   dez
-   bit $1345,x
-   and $1345,x
-   rol $1345,x
-   bbr3 $02,*+$34
-
-   rti
-   eor ($05,x)
-   neg
-   asr
-   asr $02
-   eor $02
-   lsr $02
-   rmb4 $02
-   pha
-   eor #$01
-   lsr
-   taz
-   jmp $1234
-   eor $1234
-   lsr $1234
-   bbr4 $02,*+$34
-
-   bvc *+$32
-   eor ($06),y
-   eor ($07),z
-   lbvc *+$3133 ; bvc *+$3133
-   asr $03,x
-   eor $03,x
-   lsr $03,x
-   rmb5 $02
-   cli
-   eor $1456,y
-   phy
-   tab
-   map
-   eor $1345,x
-   lsr $1345,x
-   bbr5 $02,*+$34
-
-   rts
-   adc ($05,x)
-   rtn #$09
-   bsr *+$3133
-   stz $02
-   adc $02
-   ror $02
-   rmb6 $02
-   pla
-   adc #$01
-   ror
-   tza
-   jmp ($2345)
-   adc $1234
-   ror $1234
-   bbr6 $02,*+$34
-
-   bvs *+$32
-   adc ($06),y
-   adc ($07),z
-   lbvs *+$3133 ; bvs *+$3133
-   stz $03,x
-   adc $03,x
-   ror $03,x
-   rmb7 $02
-   sei
-   adc $1456,y
-   ply
-   tba
-   jmp ($2456,x)
-   adc $1345,x
-   ror $1345,x
-   bbr7 $02,*+$34
-
-   bra *+$32
-   sta ($05,x)
-   sta ($0f,s),y
-   sta ($0f,sp),y
-   lbra *+$3133 ; bra *+$3133
-   sty $02
-   sta $02
-   stx $02
-   smb0 $02
-   dey
-   bit #$01
-   txa
-   sty $1345,x
-   sty $1234
-   sta $1234
-   stx $1234
-   bbs0 $02,*+$34
-
-   bcc *+$32
-   sta ($06),y
-   sta ($07),z
-   lbcc *+$3133 ; bcc *+$3133
-   sty $03,x
-   sta $03,x
-   stx $04,y
-   smb1 $02
-   tya
-   sta $1456,y
-   txs
-   stx $1456,y
-   stz $1234
-   sta $1345,x
-   stz $1345,x
-   bbs1 $02,*+$34
-
-   ldy #$01
-   lda ($05,x)
-   ldx #$01
-   ldz #$01
-   ldy $02
-   lda $02
-   ldx $02
-   smb2 $02
-   tay
-   lda #$01
-   tax
-   ldz $1234
-   ldy $1234
-   lda $1234
-   ldx $1234
-   bbs2 $02,*+$34
-
-   bcs *+$32
-   lda ($06),y
-   lda ($07),z
-   lbcs *+$3133 ; bcs *+$3133
-   ldy $03,x
-   lda $03,x
-   ldx $04,y
-   smb3 $02
-   clv
-   lda $1456,y
-   tsx
-   ldz $1345,x
-   ldy $1345,x
-   lda $1345,x
-   ldx $1456,y
-   bbs3 $02,*+$34
-
-   cpy #$01
-   cmp ($05,x)
-   cpz #$01
-   dew $02
-   cpy $02
-   cmp $02
-   dec $02
-   smb4 $02
-   iny
-   cmp #$01
-   dex
-   asw $1234
-   cpy $1234
-   cmp $1234
-   dec $1234
-   bbs4 $02,*+$34
-
-   bne *+$32
-   cmp ($06),y
-   cmp ($07),z
-   lbne *+$3133 ; bne *+$3133
-   cpz $02
-   cmp $03,x
-   dec $03,x
-   smb5 $02
-   cld
-   cmp $1456,y
-   phx
-   phz
-   cpz $1234
-   cmp $1345,x
-   dec $1345,x
-   bbs5 $02,*+$34
-
-   cpx #$01
-   sbc ($05,x)
-   lda ($0f,s),y
-   lda ($0f,sp),y
-   inw $02
-   cpx $02
-   sbc $02
-   inc $02
-   smb6 $02
-   inx
-   sbc #$01
-   eom
-   nop
-   row $1234
-   cpx $1234
-   sbc $1234
-   inc $1234
-   bbs6 $02,*+$34
-
-   beq *+$32
-   sbc ($06),y
-   sbc ($07),z
-   lbeq *+$3133 ; beq *+$3133
-   phd #$089a
-   phw #$089a
-   sbc $03,x
-   inc $03,x
-   smb7 $02
-   sed
-   sbc $1456,y
-   plx
-   plz
-   phd $1234
-   phw $1234
-   sbc $1345,x
-   inc $1345,x
-   bbs7 $02,*+$34
diff --git a/test/assembler/6502-cpudetect.ref b/test/assembler/6502-cpudetect.ref
deleted file mode 100644 (file)
index 9b0aeb1..0000000
Binary files a/test/assembler/6502-cpudetect.ref and /dev/null differ
diff --git a/test/assembler/6502-opcodes.ref b/test/assembler/6502-opcodes.ref
deleted file mode 100644 (file)
index c12fa8f..0000000
Binary files a/test/assembler/6502-opcodes.ref and /dev/null differ
diff --git a/test/assembler/6502-opcodes.s b/test/assembler/6502-opcodes.s
deleted file mode 100644 (file)
index 5cb94c2..0000000
+++ /dev/null
@@ -1,257 +0,0 @@
-.setcpu "6502"
-
-   brk
-   ora     ($12,x)
-   .byte   $02
-   .byte   $03
-   .byte   $04
-   ora     $12
-   asl     $12
-   .byte   $07
-   php
-   ora     #$12
-   asl     a
-   .byte   $0B
-   .byte   $0C
-   ora     $3456
-   asl     $3456
-   .byte   $0F
-   bpl     *+122
-   ora     ($12),y
-   .byte   $12
-   .byte   $13
-   .byte   $14
-   ora     $12,x
-   asl     $12,x
-   .byte   $17
-   clc
-   ora     $3456,y
-   .byte   $1A
-   .byte   $1B
-   .byte   $1C
-   ora     $3456,x
-   asl     $3456,x
-   .byte   $1F
-   jsr     $3456
-   and     ($12,x)
-   .byte   $22
-   .byte   $23
-   bit     $12
-   and     $12
-   rol     $12
-   .byte   $27
-   plp
-   and     #$12
-   rol     a
-   .byte   $2B
-   bit     $3456
-   and     $3456
-   rol     $3456
-   .byte   $2F
-   bmi     *+122
-   and     ($12),y
-   .byte   $32
-   .byte   $33
-   .byte   $34
-   and     $12,x
-   rol     $12,x
-   .byte   $37
-   sec
-   and     $3456,y
-   .byte   $3A
-   .byte   $3B
-   .byte   $3C
-   and     $3456,x
-   rol     $3456,x
-   .byte   $3F
-   rti
-   eor     ($12,x)
-   .byte   $42
-   .byte   $43
-   .byte   $44
-   eor     $12
-   lsr     $12
-   .byte   $47
-   pha
-   eor     #$12
-   lsr     a
-   .byte   $4B
-   jmp     $3456
-   eor     $3456
-   lsr     $3456
-   .byte   $4F
-   bvc     *+122
-   eor     ($12),y
-   .byte   $52
-   .byte   $53
-   .byte   $54
-   eor     $12,x
-   lsr     $12,x
-   .byte   $57
-   cli
-   eor     $3456,y
-   .byte   $5A
-   .byte   $5B
-   .byte   $5C
-   eor     $3456,x
-   lsr     $3456,x
-   .byte   $5F
-   rts
-   adc     ($12,x)
-   .byte   $62
-   .byte   $63
-   .byte   $64
-   adc     $12
-   ror     $12
-   .byte   $67
-   pla
-   adc     #$12
-   ror     a
-   .byte   $6B
-   jmp     ($3456)
-   adc     $3456
-   ror     $3456
-   .byte   $6F
-   bvs     *+122
-   adc     ($12),y
-   .byte   $72
-   .byte   $73
-   .byte   $74
-   adc     $12,x
-   ror     $12,x
-   .byte   $77
-   sei
-   adc     $3456,y
-   .byte   $7A
-   .byte   $7B
-   .byte   $7C
-   adc     $3456,x
-   ror     $3456,x
-   .byte   $7F
-   .byte   $80
-   sta     ($12,x)
-   .byte   $82
-   .byte   $83
-   sty     $12
-   sta     $12
-   stx     $12
-   .byte   $87
-   dey
-   .byte   $89
-   txa
-   .byte   $8B
-   sty     $3456
-   sta     $3456
-   stx     $3456
-   .byte   $8F
-   bcc     *+122
-   sta     ($12),y
-   .byte   $92
-   .byte   $93
-   sty     $12,x
-   sta     $12,x
-   stx     $12,y
-   .byte   $97
-   tya
-   sta     $3456,y
-   txs
-   .byte   $9B
-   .byte   $9C
-   sta     $3456,x
-   .byte   $9E
-   .byte   $9F
-   ldy     #$12
-   lda     ($12,x)
-   ldx     #$12
-   .byte   $A3
-   ldy     $12
-   lda     $12
-   ldx     $12
-   .byte   $A7
-   tay
-   lda     #$12
-   tax
-   .byte   $AB
-   ldy     $3456
-   lda     $3456
-   ldx     $3456
-   .byte   $AF
-   bcs     *+122
-   lda     ($12),y
-   .byte   $B2
-   .byte   $B3
-   ldy     $12,x
-   lda     $12,x
-   ldx     $12,y
-   .byte   $B7
-   clv
-   lda     $3456,y
-   tsx
-   .byte   $BB
-   ldy     $3456,x
-   lda     $3456,x
-   ldx     $3456,y
-   .byte   $BF
-   cpy     #$12
-   cmp     ($12,x)
-   .byte   $C2
-   .byte   $C3
-   cpy     $12
-   cmp     $12
-   dec     $12
-   .byte   $C7
-   iny
-   cmp     #$12
-   dex
-   .byte   $CB
-   cpy     $3456
-   cmp     $3456
-   dec     $3456
-   .byte   $CF
-   bne     *+122
-   cmp     ($12),y
-   .byte   $D2
-   .byte   $D3
-   .byte   $D4
-   cmp     $12,x
-   dec     $12,x
-   .byte   $D7
-   cld
-   cmp     $3456,y
-   .byte   $DA
-   .byte   $DB
-   .byte   $DC
-   cmp     $3456,x
-   dec     $3456,x
-   .byte   $DF
-   cpx     #$12
-   sbc     ($12,x)
-   .byte   $E2
-   .byte   $E3
-   cpx     $12
-   sbc     $12
-   inc     $12
-   .byte   $E7
-   inx
-   sbc     #$12
-   .byte   $EB
-   cpx     $3456
-   sbc     $3456
-   inc     $3456
-   .byte   $EF
-   beq     *+122
-   sbc     ($12),y
-   .byte   $F2
-   .byte   $F3
-   .byte   $F4
-   sbc     $12,x
-   inc     $12,x
-   .byte   $F7
-   sed
-   sbc     $3456,y
-   .byte   $FA
-   .byte   $FB
-   .byte   $FC
-   sbc     $3456,x
-   inc     $3456,x
-   .byte   $FF
diff --git a/test/assembler/6502x-cpudetect.ref b/test/assembler/6502x-cpudetect.ref
deleted file mode 100644 (file)
index 3434ecb..0000000
Binary files a/test/assembler/6502x-cpudetect.ref and /dev/null differ
diff --git a/test/assembler/6502x-opcodes.ref b/test/assembler/6502x-opcodes.ref
deleted file mode 100644 (file)
index f942bec..0000000
Binary files a/test/assembler/6502x-opcodes.ref and /dev/null differ
diff --git a/test/assembler/6502x-opcodes.s b/test/assembler/6502x-opcodes.s
deleted file mode 100644 (file)
index 5f21aeb..0000000
+++ /dev/null
@@ -1,258 +0,0 @@
-.setcpu "6502X"
-
-   brk
-   ora     ($12,x)
-   jam
-   slo     ($12,x)
-   nop     $12
-   ora     $12
-   asl     $12
-   slo     $12
-   php
-   ora     #$12
-   asl     a
-   anc     #$12
-   nop     $3456
-   ora     $3456
-   asl     $3456
-   slo     $3456
-   bpl     *+122
-   ora     ($12),y
-   .byte   $12         ; jam
-   slo     ($12),y
-   nop     $12,x
-   ora     $12,x
-   asl     $12,x
-   slo     $12,x
-   clc
-   ora     $3456,y
-   .byte   $1a         ; nop
-   slo     $3456,y
-   nop     $3456,x
-   ora     $3456,x
-   asl     $3456,x
-   slo     $3456,x
-   jsr     $3456
-   and     ($12,x)
-   .byte   $22         ; jam
-   rla     ($12,x)
-   bit     $12
-   and     $12
-   rol     $12
-   rla     $12
-   plp
-   and     #$12
-   rol     a
-   .byte   $2b         ; anc     #$12
-   bit     $3456
-   and     $3456
-   rol     $3456
-   rla     $3456
-   bmi     *+122
-   and     ($12),y
-   .byte   $32         ; jam
-   rla     ($12),y
-   .byte   $34,$12     ; nop     $12,x
-   and     $12,x
-   rol     $12,x
-   rla     $12,x
-   sec
-   and     $3456,y
-   .byte   $3a         ; nop
-   rla     $3456,y
-   .byte   $3c,$56,$34 ; nop     $3456,x
-   and     $3456,x
-   rol     $3456,x
-   rla     $3456,x
-   rti
-   eor     ($12,x)
-   .byte   $42         ; jam
-   sre     ($12,x)
-   .byte   $44,$12     ; nop     $12
-   eor     $12
-   lsr     $12
-   sre     $12
-   pha
-   eor     #$12
-   lsr     a
-   alr     #$12
-   jmp     $3456
-   eor     $3456
-   lsr     $3456
-   sre     $3456
-   bvc     *+122
-   eor     ($12),y
-   .byte   $52         ; jam
-   sre     ($12),y
-   .byte   $54,$12     ; nop     $12,x
-   eor     $12,x
-   lsr     $12,x
-   sre     $12,x
-   cli
-   eor     $3456,y
-   .byte   $5a         ; nop
-   sre     $3456,y
-   nop     $3456,x
-   eor     $3456,x
-   lsr     $3456,x
-   sre     $3456,x
-   rts
-   adc     ($12,x)
-   .byte   $62         ; jam
-   rra     ($12,x)
-   .byte   $64,$12     ; nop     $12
-   adc     $12
-   ror     $12
-   rra     $12
-   pla
-   adc     #$12
-   ror     a
-   arr     #$12
-   jmp     ($3456)
-   adc     $3456
-   ror     $3456
-   rra     $3456
-   bvs     *+122
-   adc     ($12),y
-   .byte   $72         ; jam
-   rra     ($12),y
-   .byte   $74,$12     ; nop     $12,x
-   adc     $12,x
-   ror     $12,x
-   rra     $12,x
-   sei
-   adc     $3456,y
-   .byte   $7a         ; nop
-   rra     $3456,y
-   .byte   $7c,$56,$34 ; nop     $3456,x
-   adc     $3456,x
-   ror     $3456,x
-   rra     $3456,x
-   nop     #$12
-   sta     ($12,x)
-   .byte   $82,$12     ; nop     #$12
-   sax     ($12,x)
-   sty     $12
-   sta     $12
-   stx     $12
-   sax     $12
-   dey
-   .byte   $89,$12     ; nop     #$12
-   txa
-   .byte   $8b,$12     ; xaa     #$12
-   sty     $3456
-   sta     $3456
-   stx     $3456
-   sax     $3456
-   bcc     *+122
-   sta     ($12),y
-   .byte   $92     ; jam
-   .byte   $93,$12 ; ahx     ($12),y
-   sty     $12,x
-   sta     $12,x
-   stx     $12,y
-   sax     $12,y
-   tya
-   sta     $3456,y
-   txs
-   tas     $3456,y
-   shy     $3456,x
-   sta     $3456,x
-   shx     $3456,y
-   .byte   $9f,$56,$34 ;  ahx     $3456,y
-   ldy     #$12
-   lda     ($12,x)
-   ldx     #$12
-   lax     ($12,x)
-   ldy     $12
-   lda     $12
-   ldx     $12
-   lax     $12
-   tay
-   lda     #$12
-   tax
-   lax     #$12
-   ldy     $3456
-   lda     $3456
-   ldx     $3456
-   lax     $3456
-   bcs     *+122
-   lda     ($12),y
-   .byte   $b2     ; jam
-   lax     ($12),y
-   ldy     $12,x
-   lda     $12,x
-   ldx     $12,y
-   lax     $12,y
-   clv
-   lda     $3456,y
-   tsx
-   las     $3456,y
-   ldy     $3456,x
-   lda     $3456,x
-   ldx     $3456,y
-   lax     $3456,y
-   cpy     #$12
-   cmp     ($12,x)
-   .byte   $c2,$12     ; nop     #$12
-   dcp     ($12,x)
-   cpy     $12
-   cmp     $12
-   dec     $12
-   dcp     $12
-   iny
-   cmp     #$12
-   dex
-   axs     #$12
-   cpy     $3456
-   cmp     $3456
-   dec     $3456
-   dcp     $3456
-   bne     *+122
-   cmp     ($12),y
-   .byte   $d2         ; jam
-   dcp     ($12),y
-   .byte   $d4,$12     ; nop     $12,x
-   cmp     $12,x
-   dec     $12,x
-   dcp     $12,x
-   cld
-   cmp     $3456,y
-   .byte   $da         ; nop
-   dcp     $3456,y
-   .byte   $dc,$56,$34 ; nop     $3456,x
-   cmp     $3456,x
-   dec     $3456,x
-   dcp     $3456,x
-   cpx     #$12
-   sbc     ($12,x)
-   .byte   $e2,$12     ; nop     #$12
-   isc     ($12,x)
-   cpx     $12
-   sbc     $12
-   inc     $12
-   isc     $12
-   inx
-   sbc     #$12
-   nop
-   .byte   $eb         ; nop
-   cpx     $3456
-   sbc     $3456
-   inc     $3456
-   isc     $3456
-   beq     *+122
-   sbc     ($12),y
-   .byte   $f2         ; jam
-   isc     ($12),y
-   .byte   $f4,$12     ; nop     $12,x
-   sbc     $12,x
-   inc     $12,x
-   isc     $12,x
-   sed
-   sbc     $3456,y
-   .byte   $fa         ; nop
-   isc     $3456,y
-   .byte   $fc,$56,$34 ; nop     $3456,x
-   sbc     $3456,x
-   inc     $3456,x
-   isc     $3456,x
diff --git a/test/assembler/65816-cpudetect.ref b/test/assembler/65816-cpudetect.ref
deleted file mode 100644 (file)
index 4f6e767..0000000
Binary files a/test/assembler/65816-cpudetect.ref and /dev/null differ
diff --git a/test/assembler/65c02-cpudetect.ref b/test/assembler/65c02-cpudetect.ref
deleted file mode 100644 (file)
index 9f790d5..0000000
Binary files a/test/assembler/65c02-cpudetect.ref and /dev/null differ
diff --git a/test/assembler/65c02-opcodes.ref b/test/assembler/65c02-opcodes.ref
deleted file mode 100644 (file)
index 2d44045..0000000
Binary files a/test/assembler/65c02-opcodes.ref and /dev/null differ
diff --git a/test/assembler/65c02-opcodes.s b/test/assembler/65c02-opcodes.s
deleted file mode 100644 (file)
index 09c3f04..0000000
+++ /dev/null
@@ -1,258 +0,0 @@
-.setcpu "65C02"
-
-   brk
-   ora     ($12,x)
-   .byte   $02
-   .byte   $03
-   tsb     $12
-   ora     $12
-   asl     $12
-   rmb0    $12
-   php
-   ora     #$12
-   asl     a
-   .byte   $0B
-   tsb     $3456
-   ora     $3456
-   asl     $3456
-   bbr0    $12,*+122
-   bpl     *+122
-   ora     ($12),y
-   ora     ($12)
-   .byte   $13
-   trb     $12
-   ora     $12,x
-   asl     $12,x
-   rmb1    $12
-   clc
-   ora     $3456,y
-   inc     a
-   .byte   $1B
-   trb     $3456
-   ora     $3456,x
-   asl     $3456,x
-   bbr1    $12,*+122
-   jsr     $3456
-   and     ($12,x)
-   .byte   $22
-   .byte   $23
-   bit     $12
-   and     $12
-   rol     $12
-   rmb2    $12
-   plp
-   and     #$12
-   rol     a
-   .byte   $2B
-   bit     $3456
-   and     $3456
-   rol     $3456
-   bbr2    $12,*+122
-   bmi     *+122
-   and     ($12),y
-   and     ($12)
-   .byte   $33
-   bit     $12,x
-   and     $12,x
-   rol     $12,x
-   rmb3    $12
-   sec
-   and     $3456,y
-   dec     a
-   .byte   $3B
-   bit     $3456,x
-   and     $3456,x
-   rol     $3456,x
-   bbr3    $12,*+122
-   rti
-   eor     ($12,x)
-   .byte   $42
-   .byte   $43
-   .byte   $44
-   eor     $12
-   lsr     $12
-   rmb4    $12
-   pha
-   eor     #$12
-   lsr     a
-   .byte   $4B
-   jmp     $3456
-   eor     $3456
-   lsr     $3456
-   bbr4    $12,*+122
-   bvc     *+122
-   eor     ($12),y
-   eor     ($12)
-   .byte   $53
-   .byte   $54
-   eor     $12,x
-   lsr     $12,x
-   rmb5    $12
-   cli
-   eor     $3456,y
-   phy
-   .byte   $5B
-   .byte   $5C
-   eor     $3456,x
-   lsr     $3456,x
-   bbr5    $12,*+122
-   rts
-   adc     ($12,x)
-   .byte   $62
-   .byte   $63
-   stz     $12
-   adc     $12
-   ror     $12
-   rmb6    $12
-   pla
-   adc     #$12
-   ror     a
-   .byte   $6B
-   jmp     ($3456)
-   adc     $3456
-   ror     $3456
-   bbr6    $12,*+122
-   bvs     *+122
-   adc     ($12),y
-   adc     ($12)
-   .byte   $73
-   stz     $12,x
-   adc     $12,x
-   ror     $12,x
-   rmb7    $12
-   sei
-   adc     $3456,y
-   ply
-   .byte   $7B
-   jmp     ($3456,x)
-   adc     $3456,x
-   ror     $3456,x
-   bbr7    $12,*+122
-   bra     *+122
-   sta     ($12,x)
-   .byte   $82
-   .byte   $83
-   sty     $12
-   sta     $12
-   stx     $12
-   smb0    $12
-   dey
-   bit     #$12
-   txa
-   .byte   $8B
-   sty     $3456
-   sta     $3456
-   stx     $3456
-   bbs0    $12,*+122
-   bcc     *+122
-   sta     ($12),y
-   sta     ($12)
-   .byte   $93
-   sty     $12,x
-   sta     $12,x
-   stx     $12,y
-   smb1    $12
-   tya
-   sta     $3456,y
-   txs
-   .byte   $9B
-   stz     $3456
-   sta     $3456,x
-   stz     $3456,x
-   bbs1    $12,*+122
-   ldy     #$12
-   lda     ($12,x)
-   ldx     #$12
-   .byte   $A3
-   ldy     $12
-   lda     $12
-   ldx     $12
-   smb2    $12
-   tay
-   lda     #$12
-   tax
-   .byte   $AB
-   ldy     $3456
-   lda     $3456
-   ldx     $3456
-   bbs2    $12,*+122
-   bcs     *+122
-   lda     ($12),y
-   lda     ($12)
-   .byte   $B3
-   ldy     $12,x
-   lda     $12,x
-   ldx     $12,y
-   smb3    $12
-   clv
-   lda     $3456,y
-   tsx
-   .byte   $BB
-   ldy     $3456,x
-   lda     $3456,x
-   ldx     $3456,y
-   bbs3    $12,*+122
-   cpy     #$12
-   cmp     ($12,x)
-   .byte   $C2
-   .byte   $C3
-   cpy     $12
-   cmp     $12
-   dec     $12
-   smb4    $12
-   iny
-   cmp     #$12
-   dex
-   .byte   $CB
-   cpy     $3456
-   cmp     $3456
-   dec     $3456
-   bbs4    $12,*+122
-   bne     *+122
-   cmp     ($12),y
-   cmp     ($12)
-   .byte   $D3
-   .byte   $D4
-   cmp     $12,x
-   dec     $12,x
-   smb5    $12
-   cld
-   cmp     $3456,y
-   phx
-   .byte   $DB
-   .byte   $DC
-   cmp     $3456,x
-   dec     $3456,x
-   bbs5    $12,*+122
-   cpx     #$12
-   sbc     ($12,x)
-   .byte   $E2
-   .byte   $E3
-   cpx     $12
-   sbc     $12
-   inc     $12
-   smb6    $12
-   inx
-   sbc     #$12
-   nop
-   .byte   $EB
-   cpx     $3456
-   sbc     $3456
-   inc     $3456
-   bbs6    $12,*+122
-   beq     *+122
-   sbc     ($12),y
-   sbc     ($12)
-   .byte   $F3
-   .byte   $F4
-   sbc     $12,x
-   inc     $12,x
-   smb7    $12
-   sed
-   sbc     $3456,y
-   plx
-   .byte   $FB
-   .byte   $FC
-   sbc     $3456,x
-   inc     $3456,x
-   bbs7    $12,*+122
diff --git a/test/assembler/65sc02-cpudetect.ref b/test/assembler/65sc02-cpudetect.ref
deleted file mode 100644 (file)
index 4e11bd7..0000000
Binary files a/test/assembler/65sc02-cpudetect.ref and /dev/null differ
diff --git a/test/assembler/65sc02-opcodes.ref b/test/assembler/65sc02-opcodes.ref
deleted file mode 100644 (file)
index d22fe66..0000000
Binary files a/test/assembler/65sc02-opcodes.ref and /dev/null differ
diff --git a/test/assembler/65sc02-opcodes.s b/test/assembler/65sc02-opcodes.s
deleted file mode 100644 (file)
index aa53991..0000000
+++ /dev/null
@@ -1,258 +0,0 @@
-.setcpu "65SC02"
-
-   brk
-   ora     ($12,x)
-   .byte   $02
-   .byte   $03
-   tsb     $12
-   ora     $12
-   asl     $12
-   .byte   $07
-   php
-   ora     #$12
-   asl     a
-   .byte   $0B
-   tsb     $3456
-   ora     $3456
-   asl     $3456
-   .byte   $0F
-   bpl     *+122
-   ora     ($12),y
-   ora     ($12)
-   .byte   $13
-   trb     $12
-   ora     $12,x
-   asl     $12,x
-   .byte   $17
-   clc
-   ora     $3456,y
-   inc     a
-   .byte   $1B
-   trb     $3456
-   ora     $3456,x
-   asl     $3456,x
-   .byte   $1F
-   jsr     $3456
-   and     ($12,x)
-   .byte   $22
-   .byte   $23
-   bit     $12
-   and     $12
-   rol     $12
-   .byte   $27
-   plp
-   and     #$12
-   rol     a
-   .byte   $2B
-   bit     $3456
-   and     $3456
-   rol     $3456
-   .byte   $2F
-   bmi     *+122
-   and     ($12),y
-   and     ($12)
-   .byte   $33
-   bit     $12,x
-   and     $12,x
-   rol     $12,x
-   .byte   $37
-   sec
-   and     $3456,y
-   dec     a
-   .byte   $3B
-   bit     $3456,x
-   and     $3456,x
-   rol     $3456,x
-   .byte   $3F
-   rti
-   eor     ($12,x)
-   .byte   $42
-   .byte   $43
-   .byte   $44
-   eor     $12
-   lsr     $12
-   .byte   $47
-   pha
-   eor     #$12
-   lsr     a
-   .byte   $4B
-   jmp     $3456
-   eor     $3456
-   lsr     $3456
-   .byte   $4F
-   bvc     *+122
-   eor     ($12),y
-   eor     ($12)
-   .byte   $53
-   .byte   $54
-   eor     $12,x
-   lsr     $12,x
-   .byte   $57
-   cli
-   eor     $3456,y
-   phy
-   .byte   $5B
-   .byte   $5C
-   eor     $3456,x
-   lsr     $3456,x
-   .byte   $5F
-   rts
-   adc     ($12,x)
-   .byte   $62
-   .byte   $63
-   stz     $12
-   adc     $12
-   ror     $12
-   .byte   $67
-   pla
-   adc     #$12
-   ror     a
-   .byte   $6B
-   jmp     ($3456)
-   adc     $3456
-   ror     $3456
-   .byte   $6F
-   bvs     *+122
-   adc     ($12),y
-   adc     ($12)
-   .byte   $73
-   stz     $12,x
-   adc     $12,x
-   ror     $12,x
-   .byte   $77
-   sei
-   adc     $3456,y
-   ply
-   .byte   $7B
-   jmp     ($3456,x)
-   adc     $3456,x
-   ror     $3456,x
-   .byte   $7F
-   bra     *+122
-   sta     ($12,x)
-   .byte   $82
-   .byte   $83
-   sty     $12
-   sta     $12
-   stx     $12
-   .byte   $87
-   dey
-   bit     #$12
-   txa
-   .byte   $8B
-   sty     $3456
-   sta     $3456
-   stx     $3456
-   .byte   $8F
-   bcc     *+122
-   sta     ($12),y
-   sta     ($12)
-   .byte   $93
-   sty     $12,x
-   sta     $12,x
-   stx     $12,y
-   .byte   $97
-   tya
-   sta     $3456,y
-   txs
-   .byte   $9B
-   stz     $3456
-   sta     $3456,x
-   stz     $3456,x
-   .byte   $9F
-   ldy     #$12
-   lda     ($12,x)
-   ldx     #$12
-   .byte   $A3
-   ldy     $12
-   lda     $12
-   ldx     $12
-   .byte   $A7
-   tay
-   lda     #$12
-   tax
-   .byte   $AB
-   ldy     $3456
-   lda     $3456
-   ldx     $3456
-   .byte   $AF
-   bcs     *+122
-   lda     ($12),y
-   lda     ($12)
-   .byte   $B3
-   ldy     $12,x
-   lda     $12,x
-   ldx     $12,y
-   .byte   $B7
-   clv
-   lda     $3456,y
-   tsx
-   .byte   $BB
-   ldy     $3456,x
-   lda     $3456,x
-   ldx     $3456,y
-   .byte   $BF
-   cpy     #$12
-   cmp     ($12,x)
-   .byte   $C2
-   .byte   $C3
-   cpy     $12
-   cmp     $12
-   dec     $12
-   .byte   $C7
-   iny
-   cmp     #$12
-   dex
-   .byte   $CB
-   cpy     $3456
-   cmp     $3456
-   dec     $3456
-   .byte   $CF
-   bne     *+122
-   cmp     ($12),y
-   cmp     ($12)
-   .byte   $D3
-   .byte   $D4
-   cmp     $12,x
-   dec     $12,x
-   .byte   $D7
-   cld
-   cmp     $3456,y
-   phx
-   .byte   $DB
-   .byte   $DC
-   cmp     $3456,x
-   dec     $3456,x
-   .byte   $DF
-   cpx     #$12
-   sbc     ($12,x)
-   .byte   $E2
-   .byte   $E3
-   cpx     $12
-   sbc     $12
-   inc     $12
-   .byte   $E7
-   inx
-   sbc     #$12
-   nop
-   .byte   $EB
-   cpx     $3456
-   sbc     $3456
-   inc     $3456
-   .byte   $EF
-   beq     *+122
-   sbc     ($12),y
-   sbc     ($12)
-   .byte   $F3
-   .byte   $F4
-   sbc     $12,x
-   inc     $12,x
-   .byte   $F7
-   sed
-   sbc     $3456,y
-   plx
-   .byte   $FB
-   .byte   $FC
-   sbc     $3456,x
-   inc     $3456,x
-   .byte   $FF
diff --git a/test/assembler/Makefile b/test/assembler/Makefile
deleted file mode 100644 (file)
index 5d38847..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-
-# makefile for the assembler regression tests
-
-BINDIR = ../../bin
-WORKDIR := ../../testwrk
-
-BASE_TARGETS  = 6502 6502x 65sc02 65c02
-BASE_TARGETS += 4510 huc6280
-
-OPCODE_TARGETS = $(BASE_TARGETS)
-CPUDETECT_TARGETS = $(BASE_TARGETS)
-
-CPUDETECT_TARGETS += 65816
-
-# default target defined later
-all:
-
-# generate opcode targets and expand target list
-define opcode
-OPCODE_TARGETLIST += $$(WORKDIR)/$(1)-opcodes.bin
-$$(WORKDIR)/$(1)-opcodes.bin: $(1)-opcodes.s
-       @$$(BINDIR)/cl65 --cpu $(1) -t none -l $$(WORKDIR)/$(1)-opcodes.lst --obj-path $$(WORKDIR) -o $$@ $$<
-       @diff -q $(1)-opcodes.ref $$@ || (cat $$(WORKDIR)/$(1)-opcodes.lst ; exit 1)
-       @echo ca65 --cpu $(1) opcodes ok
-       @rm -f $(1)-opcodes.o #workaround for #168
-endef
-$(foreach target,$(OPCODE_TARGETS),$(eval $(call opcode,$(target))))
-
-# generate cpudetect targets and expand target list
-define cpudetect
-CPUDETECT_TARGETLIST += $$(WORKDIR)/$(1)-cpudetect.bin
-$$(WORKDIR)/$(1)-cpudetect.bin: cpudetect.s
-       @$$(BINDIR)/cl65 --cpu $(1) -t none -l $$(WORKDIR)/$(1)-cpudetect.lst --obj-path $$(WORKDIR) -o $$@ $$<
-       @diff -q $(1)-cpudetect.ref $$@ || (cat $$(WORKDIR)/$(1)-cpudetect.lst ; exit 1)
-       @echo ca65 --cpu $(1) cpudetect ok
-       @rm -f cpudetect.o #workaround for #168
-endef
-$(foreach target,$(CPUDETECT_TARGETS),$(eval $(call cpudetect,$(target))))
-
-# now that all targets have been generated, get to the manual ones
-all: $(OPCODE_TARGETLIST) $(CPUDETECT_TARGETLIST)
-       @#
-
-.PHONY: all $(OPCODE_TARGETLIST) $(CPUDETECT_TARGETLIST)
-
diff --git a/test/assembler/README b/test/assembler/README
deleted file mode 100644 (file)
index a2b1e9a..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-
-Assembler Testcases
-===================
-
-Opcode Tests:
--------------
-
-These testcases are inspired by the ones now removed from test/assembler.
-The main purpose is to have each possible opcode generated at least once,
-either by an assembly instruction or a ".byte"-placeholder. Typically
-generated by disassembling a binary dump that contains data in the form
-of the pattern that each opcode is stated once in order followed by easy
-to recognise:
-
-00 00 EA 00
-01 00 EA 00
-02 00 EA 00
-[...]
-fe 00 EA 00
-ff 00 EA 00
-
-The disassembly is then put in a better readable form by replacing the
-leftover dummy opcode parameters with something more recognizable.
-
-The testcases for 6502, 6502x, 65sc02, 65c02, 4510, and huc6280 have been
-put together by Sven Oliver ("SvOlli") Moll, as well as a template for the
-m740 instructions set.
-
-Still to do is to find a way to implement an opcode testcase for the 65816
-processor, since it's capable of executing instructions with an 8-bit and
-a 16-bit operator alike, only distinguished by one processor flag.
-
-
-CPU detect Tests
-----------------
-
-These tests all assemble the same file "cpudetect.s" which contains several
-conditionals for several CPUs, only using every option known to the "--cpu"
-commandline switch of ca65/cl65.
-
-
-Reference (".ref") Files
-------------------------
-
-A hint on creating these files: when running the test, it will fail due to
-the missing ".ref" file. Review the output of the ".lst" very pedantic, then
-copy the ".bin" to the ".ref" file.
-
diff --git a/test/assembler/cpudetect.s b/test/assembler/cpudetect.s
deleted file mode 100644 (file)
index adad7c1..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-
-.macpack cpu
-
-; step 1: try to assemble an instruction that's exclusive to this set
-;         (when possible)
-
-.ifp02
-   lda #$ea
-.endif
-
-.ifpsc02
-   jmp ($1234,x)
-.endif
-
-.ifpc02
-   rmb0 $12
-.endif
-
-.ifp816
-   xba
-.endif
-
-.ifp4510
-   taz
-.endif
-
-
-; step 2: check for bitwise compatibility of instructions sets
-;         (made verbose for better reading with hexdump/hd(1))
-
-.if (.cpu .bitand CPU_ISET_NONE)
-   .byte 0,"CPU_ISET_NONE"
-.endif
-
-.if (.cpu .bitand CPU_ISET_6502)
-   .byte 0,"CPU_ISET_6502"
-.endif
-
-.if (.cpu .bitand CPU_ISET_6502X)
-   .byte 0,"CPU_ISET_6502X"
-.endif
-
-.if (.cpu .bitand CPU_ISET_65SC02)
-   .byte 0,"CPU_ISET_65SC02"
-.endif
-
-.if (.cpu .bitand CPU_ISET_65C02)
-   .byte 0,"CPU_ISET_65C02"
-.endif
-
-.if (.cpu .bitand CPU_ISET_65816)
-   .byte 0,"CPU_ISET_65816"
-.endif
-
-.if (.cpu .bitand CPU_ISET_SWEET16)
-   .byte 0,"CPU_ISET_SWEET16"
-.endif
-
-.if (.cpu .bitand CPU_ISET_HUC6280)
-   .byte 0,"CPU_ISET_HUC6280"
-.endif
-
-.if (.cpu .bitand CPU_ISET_4510)
-   .byte 0,"CPU_ISET_4510"
-.endif
-
diff --git a/test/assembler/huc6280-cpudetect.ref b/test/assembler/huc6280-cpudetect.ref
deleted file mode 100644 (file)
index 646e0f4..0000000
Binary files a/test/assembler/huc6280-cpudetect.ref and /dev/null differ
diff --git a/test/assembler/huc6280-opcodes.ref b/test/assembler/huc6280-opcodes.ref
deleted file mode 100644 (file)
index 33f5b29..0000000
Binary files a/test/assembler/huc6280-opcodes.ref and /dev/null differ
diff --git a/test/assembler/huc6280-opcodes.s b/test/assembler/huc6280-opcodes.s
deleted file mode 100644 (file)
index bd3ad5c..0000000
+++ /dev/null
@@ -1,258 +0,0 @@
-.setcpu "huc6280"
-
-   brk
-   ora     ($12,x)
-   sxy
-   st0     #$12
-   tsb     $12
-   ora     $12
-   asl     $12
-   rmb0    $12
-   php
-   ora     #$12
-   asl     a
-   .byte   $0B
-   tsb     $3456
-   ora     $3456
-   asl     $3456
-   bbr0    $12,*+122
-   bpl     *+122
-   ora     ($12),y
-   ora     ($12)
-   st1     #$12
-   trb     $12
-   ora     $12,x
-   asl     $12,x
-   rmb1    $12
-   clc
-   ora     $3456,y
-   inc     a
-   .byte   $1B
-   trb     $3456
-   ora     $3456,x
-   asl     $3456,x
-   bbr1    $12,*+122
-   jsr     $3456
-   and     ($12,x)
-   sax
-   st2     #$12
-   bit     $12
-   and     $12
-   rol     $12
-   rmb2    $12
-   plp
-   and     #$12
-   rol     a
-   .byte   $2B
-   bit     $3456
-   and     $3456
-   rol     $3456
-   bbr2    $12,*+122
-   bmi     *+122
-   and     ($12),y
-   and     ($12)
-   .byte   $33
-   bit     $12,x
-   and     $12,x
-   rol     $12,x
-   rmb3    $12
-   sec
-   and     $3456,y
-   dec     a
-   .byte   $3B
-   bit     $3456,x
-   and     $3456,x
-   rol     $3456,x
-   bbr3    $12,*+122
-   rti
-   eor     ($12,x)
-   say
-   tma     #$02
-   bsr     *+122
-   eor     $12
-   lsr     $12
-   rmb4    $12
-   pha
-   eor     #$12
-   lsr     a
-   .byte   $4B
-   jmp     $3456
-   eor     $3456
-   lsr     $3456
-   bbr4    $12,*+122
-   bvc     *+122
-   eor     ($12),y
-   eor     ($12)
-   tam     #$12
-   csl
-   eor     $12,x
-   lsr     $12,x
-   rmb5    $12
-   cli
-   eor     $3456,y
-   phy
-   .byte   $5B
-   .byte   $5C
-   eor     $3456,x
-   lsr     $3456,x
-   bbr5    $12,*+122
-   rts
-   adc     ($12,x)
-   cla
-   .byte   $63
-   stz     $12
-   adc     $12
-   ror     $12
-   rmb6    $12
-   pla
-   adc     #$12
-   ror     a
-   .byte   $6B
-   jmp     ($3456)
-   adc     $3456
-   ror     $3456
-   bbr6    $12,*+122
-   bvs     *+122
-   adc     ($12),y
-   adc     ($12)
-   tii     $3333,$7373,$1111
-   stz     $12,x
-   adc     $12,x
-   ror     $12,x
-   rmb7    $12
-   sei
-   adc     $3456,y
-   ply
-   .byte   $7B
-   jmp     ($3456,x)
-   adc     $3456,x
-   ror     $3456,x
-   bbr7    $12,*+122
-   bra     *+122
-   sta     ($12,x)
-   clx
-   tst     #$12,$EA
-   sty     $12
-   sta     $12
-   stx     $12
-   smb0    $12
-   dey
-   bit     #$12
-   txa
-   .byte   $8B
-   sty     $3456
-   sta     $3456
-   stx     $3456
-   bbs0    $12,*+122
-   bcc     *+122
-   sta     ($12),y
-   sta     ($12)
-   tst     #$12,$EAEA
-   sty     $12,x
-   sta     $12,x
-   stx     $12,y
-   smb1    $12
-   tya
-   sta     $3456,y
-   txs
-   .byte   $9B
-   stz     $3456
-   sta     $3456,x
-   stz     $3456,x
-   bbs1    $12,*+122
-   ldy     #$12
-   lda     ($12,x)
-   ldx     #$12
-   tst     #$12,$EA,x
-   ldy     $12
-   lda     $12
-   ldx     $12
-   smb2    $12
-   tay
-   lda     #$12
-   tax
-   .byte   $AB
-   ldy     $3456
-   lda     $3456
-   ldx     $3456
-   bbs2    $12,*+122
-   bcs     *+122
-   lda     ($12),y
-   lda     ($12)
-   tst     #$12,$EAEA,x
-   ldy     $12,x
-   lda     $12,x
-   ldx     $12,y
-   smb3    $12
-   clv
-   lda     $3456,y
-   tsx
-   .byte   $BB
-   ldy     $3456,x
-   lda     $3456,x
-   ldx     $3456,y
-   bbs3    $12,*+122
-   cpy     #$12
-   cmp     ($12,x)
-   cly
-   tdd     $3333,$C3C3,$1111
-   cpy     $12
-   cmp     $12
-   dec     $12
-   smb4    $12
-   iny
-   cmp     #$12
-   dex
-   .byte   $CB
-   cpy     $3456
-   cmp     $3456
-   dec     $3456
-   bbs4    $12,*+122
-   bne     *+122
-   cmp     ($12),y
-   cmp     ($12)
-   tin     $3333,$D3D3,$1111
-   .byte   $D4
-   cmp     $12,x
-   dec     $12,x
-   smb5    $12
-   cld
-   cmp     $3456,y
-   phx
-   .byte   $DB
-   .byte   $DC
-   cmp     $3456,x
-   dec     $3456,x
-   bbs5    $12,*+122
-   cpx     #$12
-   sbc     ($12,x)
-   .byte   $E2
-   tia     $3333,$E3E3,$1111
-   cpx     $12
-   sbc     $12
-   inc     $12
-   smb6    $12
-   inx
-   sbc     #$12
-   nop
-   .byte   $EB
-   cpx     $3456
-   sbc     $3456
-   inc     $3456
-   bbs6    $12,*+122
-   beq     *+122
-   sbc     ($12),y
-   sbc     ($12)
-   tai     $3333,$F3F3,$1111
-   .byte   $F4
-   sbc     $12,x
-   inc     $12,x
-   smb7    $12
-   sed
-   sbc     $3456,y
-   plx
-   .byte   $FB
-   .byte   $FC
-   sbc     $3456,x
-   inc     $3456,x
-   bbs7    $12,*+122
diff --git a/test/assembler/m740-opcodes.s b/test/assembler/m740-opcodes.s
deleted file mode 100644 (file)
index df6d714..0000000
+++ /dev/null
@@ -1,260 +0,0 @@
-.setcpu "65C02"
-; copy of 65c02, comments note changes to the m740 according to
-; http://documentation.renesas.com/doc/products/mpumcu/rej09b0322_740sm.pdf
-
-   brk
-   ora     ($12,x)
-   .byte   $02,$00,$00 ; jsr zp,ind
-   .byte   $03,$00,$00 ; bbs 0,a
-   tsb     $12         ; .byte $04
-   ora     $12
-   asl     $12
-   rmb0    $12         ; bbs 0,zp
-   php
-   ora     #$12
-   asl     a
-   .byte   $0B,$00,$00 ; seb 0,a
-   tsb     $3456       ; .byte $0c
-   ora     $3456
-   asl     $3456
-   bbr0    $12,*+122   ; seb 0,zp
-   bpl     *+122
-   ora     ($12),y
-   ora     ($12)       ; clt
-   .byte   $13,$00,$00 ; bbc 0,a
-   trb     $12         ; .byte $14
-   ora     $12,x
-   asl     $12,x
-   rmb1    $12         ; bbc 0,zp
-   clc
-   ora     $3456,y
-   inc     a
-   .byte   $1B,$00,$00 ; clb 0,a
-   trb     $3456       ; .byte $1c
-   ora     $3456,x
-   asl     $3456,x
-   bbr1    $12,*+122   ; clb 0,zp
-   jsr     $3456
-   and     ($12,x)
-   .byte   $22,$00,$00 ; jsr sp
-   .byte   $23,$00,$00 ; bbs 1,a
-   bit     $12
-   and     $12
-   rol     $12
-   rmb2    $12         ; bbs 1,zp
-   plp
-   and     #$12
-   rol     a
-   .byte   $2B,$00,$00 ; seb 1,a
-   bit     $3456
-   and     $3456
-   rol     $3456
-   bbr2    $12,*+122   ; seb 1,zp
-   bmi     *+122
-   and     ($12),y
-   and     ($12)       ; set
-   .byte   $33,$00,$00 ; bbc 1,a
-   bit     $12,x       ; .byte $34
-   and     $12,x
-   rol     $12,x
-   rmb3    $12         ; bbc 1,zp
-   sec
-   and     $3456,y
-   dec     a
-   .byte   $3B,$00,$00 ; clb 1,a
-   bit     $3456,x     ; ldm zp
-   and     $3456,x
-   rol     $3456,x
-   bbr3    $12,*+122   ; clb 1,zp
-   rti
-   eor     ($12,x)
-   .byte   $42,$00,$00 ; stp
-   .byte   $43,$00,$00 ; bbs 2,a
-   .byte   $44,$00,$00 ; com zp
-   eor     $12
-   lsr     $12
-   rmb4    $12         ; bbs 2,zp
-   pha
-   eor     #$12
-   lsr     a
-   .byte   $4B,$00,$00 ; seb 2,a
-   jmp     $3456
-   eor     $3456
-   lsr     $3456
-   bbr4    $12,*+122   ; seb 2,zp
-   bvc     *+122
-   eor     ($12),y
-   eor     ($12)       ; .byte $52
-   .byte   $53,$00,$00 ; bbc 2,a
-   .byte   $54,$00,$00
-   eor     $12,x
-   lsr     $12,x
-   rmb5    $12         ; bbc 2,zp
-   cli
-   eor     $3456,y
-   phy
-   .byte   $5B,$00,$00 ; clb 2,a
-   .byte   $5C,$00,$00
-   eor     $3456,x
-   lsr     $3456,x
-   bbr5    $12,*+122   ; clb 2,zp
-   rts
-   adc     ($12,x)
-   .byte   $62,$00,$00 ; mul zp,x
-   .byte   $63,$00,$00 ; bbs 3,a
-   stz     $12         ; tst zp
-   adc     $12
-   ror     $12
-   rmb6    $12         ; bbs 3,zp
-   pla
-   adc     #$12
-   ror     a
-   .byte   $6B,$00,$00 ; seb 3,a
-   jmp     ($3456)
-   adc     $3456
-   ror     $3456
-   bbr6    $12,*+122   ; seb 3,zp
-   bvs     *+122
-   adc     ($12),y
-   adc     ($12)       ; .byte $72
-   .byte   $73,$00,$00 ; bbc 3,a
-   stz     $12,x       ; .byte $74
-   adc     $12,x
-   ror     $12,x
-   rmb7    $12         ; bbc 3,zp
-   sei
-   adc     $3456,y
-   ply
-   .byte   $7B,$00,$00 ; clb 3,a
-   jmp     ($3456,x)   ; .byte $7c
-   adc     $3456,x
-   ror     $3456,x
-   bbr7    $12,*+122   ; clb 3,zp
-   bra     *+122
-   sta     ($12,x)
-   .byte   $82,$00,$00 ; rrf zp
-   .byte   $83,$00,$00 ; bbs 4,a
-   sty     $12
-   sta     $12
-   stx     $12
-   smb0    $12         ; bbs 4,zp
-   dey
-   bit     #$12
-   txa
-   .byte   $8B,$00,$00 ; seb 4,a
-   sty     $3456
-   sta     $3456
-   stx     $3456
-   bbs0    $12,*+122   ; seb 4,zp
-   bcc     *+122
-   sta     ($12),y
-   sta     ($12)       ; .byte $92
-   .byte   $93,$00,$00 ; bbc 4,a
-   sty     $12,x
-   sta     $12,x
-   stx     $12,y
-   smb1    $12         ; bbc 4,zp
-   tya
-   sta     $3456,y
-   txs
-   .byte   $9B,$00,$00 ; clb 4,a
-   stz     $3456       ; .byte $9c
-   sta     $3456,x
-   stz     $3456,x     ; .byte $9e
-   bbs1    $12,*+122   ; clb 4,zp
-   ldy     #$12
-   lda     ($12,x)
-   ldx     #$12
-   .byte   $A3,$00,$00 ; bbs 5,a
-   ldy     $12
-   lda     $12
-   ldx     $12
-   smb2    $12         ; bbs 5,zp
-   tay
-   lda     #$12
-   tax
-   .byte   $AB,$00,$00 ; seb 5,a
-   ldy     $3456
-   lda     $3456
-   ldx     $3456
-   bbs2    $12,*+122   ; seb 5,zp
-   bcs     *+122
-   lda     ($12),y
-   lda     ($12)       ; .byte $b2
-   .byte   $B3,$00,$00 ; bbc 5,a
-   ldy     $12,x
-   lda     $12,x
-   ldx     $12,y
-   smb3    $12         ; bbc 5,zp
-   clv
-   lda     $3456,y
-   tsx
-   .byte   $BB,$00,$00 ; clb 5,a
-   ldy     $3456,x
-   lda     $3456,x
-   ldx     $3456,y
-   bbs3    $12,*+122   ; clb 5,zp
-   cpy     #$12
-   cmp     ($12,x)
-   .byte   $C2,$00,$00 ; wit
-   .byte   $C3,$00,$00 ; bbs 6,a
-   cpy     $12
-   cmp     $12
-   dec     $12
-   smb4    $12         ; bbs 6,zp
-   iny
-   cmp     #$12
-   dex
-   .byte   $CB,$00,$00 ; seb 6,a
-   cpy     $3456
-   cmp     $3456
-   dec     $3456
-   bbs4    $12,*+122   ; seb 6,zp
-   bne     *+122
-   cmp     ($12),y
-   cmp     ($12)       ; .byte $d2
-   .byte   $D3,$00,$00 ; bbc 6,a
-   .byte   $D4,$00,$00
-   cmp     $12,x
-   dec     $12,x
-   smb5    $12         ; bbc 6,zp
-   cld
-   cmp     $3456,y
-   phx
-   .byte   $DB,$00,$00 ; clb 6,a
-   .byte   $DC,$00,$00
-   cmp     $3456,x
-   dec     $3456,x
-   bbs5    $12,*+122   ; clb 6,zp
-   cpx     #$12
-   sbc     ($12,x)
-   .byte   $E2,$00,$00 ; div zp,x
-   .byte   $E3,$00,$00 ; bbs 7,a
-   cpx     $12
-   sbc     $12
-   inc     $12
-   smb6    $12         ; bbs 7,zp
-   inx
-   sbc     #$12
-   nop
-   .byte   $EB,$00,$00 ; seb 7,a
-   cpx     $3456
-   sbc     $3456
-   inc     $3456
-   bbs6    $12,*+122   ; seb 7,zp
-   beq     *+122
-   sbc     ($12),y
-   sbc     ($12)       ; .byte $f2
-   .byte   $F3,$00,$00 ; bbc 7,a
-   .byte   $F4,$00,$00
-   sbc     $12,x
-   inc     $12,x
-   smb7    $12         ; bbc 7,zp
-   sed
-   sbc     $3456,y
-   plx
-   .byte   $FB,$00,$00 ; clb 7,a
-   .byte   $FC,$00,$00
-   sbc     $3456,x
-   inc     $3456,x
-   bbs7    $12,*+122   ; clb 7,zp
diff --git a/test/dasm/4510-disass.s b/test/dasm/4510-disass.s
new file mode 100644 (file)
index 0000000..96ed641
--- /dev/null
@@ -0,0 +1,298 @@
+.setcpu "4510"
+
+ZP = $12
+ABS = $2345
+
+start:
+   brk
+   ora (ZP,x)
+   cle
+   see
+   tsb ZP
+   ora ZP
+   asl ZP
+   rmb0 ZP
+   php
+   ora #$01
+   asl
+   tsy
+   tsb ABS
+   ora ABS
+   asl ABS
+   bbr0 ZP,label1
+
+label1:
+   bpl label2
+   ora (ZP),y
+   ora (ZP),z
+   lbpl start ; bpl start
+   trb ZP
+   ora ZP,x
+   asl ZP,x
+   rmb1 ZP
+   clc
+   ora ABS,y
+   inc
+   inz
+   trb ABS
+   ora ABS,x
+   asl ABS,x
+   bbr1 ZP,label2
+
+label2:
+   jsr ABS
+   and (ZP,x)
+   jsr ($2345)
+   jsr ($2456,x)
+   bit ZP
+   and ZP
+   rol ZP
+   rmb2 ZP
+   plp
+   and #$01
+   rol
+   tys
+   bit ABS
+   and ABS
+   rol ABS
+   bbr2 ZP,label3
+
+label3:
+   bmi label4
+   and (ZP),y
+   and (ZP),z
+   lbmi start ; bmi start
+   bit ZP,x
+   and ZP,x
+   rol ZP,x
+   rmb3 ZP
+   sec
+   and ABS,y
+   dec
+   dez
+   bit ABS,x
+   and ABS,x
+   rol ABS,x
+   bbr3 ZP,label4
+
+label4:
+   rti
+   eor (ZP,x)
+   neg
+   asr
+   asr ZP
+   eor ZP
+   lsr ZP
+   rmb4 ZP
+   pha
+   eor #$01
+   lsr
+   taz
+   jmp ABS
+   eor ABS
+   lsr ABS
+   bbr4 ZP,label5
+
+label5:
+   bvc label6
+   eor (ZP),y
+   eor (ZP),z
+   lbvc start ; bvc start
+   asr ZP,x
+   eor ZP,x
+   lsr ZP,x
+   rmb5 ZP
+   cli
+   eor ABS,y
+   phy
+   tab
+   map
+   eor ABS,x
+   lsr ABS,x
+   bbr5 ZP,label6
+
+label6:
+   rts
+   adc (ZP,x)
+   rtn #$09
+   bsr start
+   stz ZP
+   adc ZP
+   ror ZP
+   rmb6 ZP
+   pla
+   adc #$01
+   ror
+   tza
+   jmp ($2345)
+   adc ABS
+   ror ABS
+   bbr6 ZP,label7
+
+label7:
+   bvs label8
+   adc (ZP),y
+   adc (ZP),z
+   lbvs start ; bvs start
+   stz ZP,x
+   adc ZP,x
+   ror ZP,x
+   rmb7 ZP
+   sei
+   adc ABS,y
+   ply
+   tba
+   jmp ($2456,x)
+   adc ABS,x
+   ror ABS,x
+   bbr7 ZP,label8
+
+label8:
+   bra label9
+   sta (ZP,x)
+   sta ($0f,sp),y
+   lbra start ; bra start
+   sty ZP
+   sta ZP
+   stx ZP
+   smb0 ZP
+   dey
+   bit #$01
+   txa
+   sty ABS,x
+   sty ABS
+   sta ABS
+   stx ABS
+   bbs0 ZP,label9
+
+label9:
+   bcc labelA
+   sta (ZP),y
+   sta (ZP),z
+   lbcc start ; bcc start
+   sty ZP,x
+   sta ZP,x
+   stx ZP,y
+   smb1 ZP
+   tya
+   sta ABS,y
+   txs
+   stx ABS,y
+   stz ABS
+   sta ABS,x
+   stz ABS,x
+   bbs1 ZP,labelA
+
+labelA:
+   ldy #$01
+   lda (ZP,x)
+   ldx #$01
+   ldz #$01
+   ldy ZP
+   lda ZP
+   ldx ZP
+   smb2 ZP
+   tay
+   lda #$01
+   tax
+   ldz ABS
+   ldy ABS
+   lda ABS
+   ldx ABS
+   bbs2 ZP,labelB
+
+labelB:
+   bcs labelC
+   lda (ZP),y
+   lda (ZP),z
+   lbcs start ; bcs start
+   ldy ZP,x
+   lda ZP,x
+   ldx ZP,y
+   smb3 ZP
+   clv
+   lda ABS,y
+   tsx
+   ldz ABS,x
+   ldy ABS,x
+   lda ABS,x
+   ldx ABS,y
+   bbs3 ZP,labelC
+
+labelC:
+   cpy #$01
+   cmp (ZP,x)
+   cpz #$01
+   dew ZP
+   cpy ZP
+   cmp ZP
+   dec ZP
+   smb4 ZP
+   iny
+   cmp #$01
+   dex
+   asw ABS
+   cpy ABS
+   cmp ABS
+   dec ABS
+   bbs4 ZP,labelD
+
+labelD:
+   bne labelE
+   cmp (ZP),y
+   cmp (ZP),z
+   lbne start ; bne start
+   cpz ZP
+   cmp ZP,x
+   dec ZP,x
+   smb5 ZP
+   cld
+   cmp ABS,y
+   phx
+   phz
+   cpz ABS
+   cmp ABS,x
+   dec ABS,x
+   bbs5 ZP,labelE
+
+labelE:
+   cpx #$01
+   sbc (ZP,x)
+   lda ($0f,sp),y
+   inw ZP
+   cpx ZP
+   sbc ZP
+   inc ZP
+   smb6 ZP
+   inx
+   sbc #$01
+   eom
+   nop
+   row ABS
+   cpx ABS
+   sbc ABS
+   inc ABS
+   bbs6 ZP,labelF
+
+labelF:
+   beq labelG
+   sbc (ZP),y
+   sbc (ZP),z
+   lbeq start ; beq start
+   phw #$089a
+   sbc ZP,x
+   inc ZP,x
+   smb7 ZP
+   sed
+   sbc ABS,y
+   plx
+   plz
+   phd ABS
+   phw ABS
+   sbc ABS,x
+   inc ABS,x
+   bbs7 ZP,labelG
+
+labelG:
+   brk
+
diff --git a/test/dasm/Makefile b/test/dasm/Makefile
new file mode 100644 (file)
index 0000000..d707114
--- /dev/null
@@ -0,0 +1,69 @@
+# Makefile for the disassembler regression tests
+
+ifneq ($(shell echo),)
+  CMD_EXE = 1
+endif
+
+ifdef CMD_EXE
+  EXE = .exe
+  MKDIR = mkdir $(subst /,\,$1)
+  RMDIR = -rmdir /s /q $(subst /,\,$1)
+  DEL = del /f $(subst /,\,$1)
+else
+  EXE =
+  MKDIR = mkdir -p $1
+  RMDIR = $(RM) -r $1
+  DEL = $(RM) $1
+endif
+
+ifdef QUIET
+  .SILENT:
+endif
+
+CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
+DA65 := $(if $(wildcard ../../bin/da65*),../../bin/da65,da65)
+
+WORKDIR = ../../testwrk/dasm
+
+DIFF = $(WORKDIR)/bdiff$(EXE)
+
+CC = gcc
+CFLAGS = -O2
+
+START = --start-addr 0x8000
+
+.PHONY: all clean
+
+SOURCES := $(wildcard *.s)
+CPUS = $(foreach src,$(SOURCES),$(src:%-disass.s=%))
+BINS = $(foreach cpu,$(CPUS),$(WORKDIR)/$(cpu)-reass.bin)
+
+# default target defined later
+all: $(BINS)
+
+$(WORKDIR):
+       $(call MKDIR,$(WORKDIR))
+
+$(DIFF): ../bdiff.c | $(WORKDIR)
+       $(CC) $(CFLAGS) -o $@ $<
+
+define DISASS_template
+
+$(WORKDIR)/$1-disass.bin: $1-disass.s | $(WORKDIR)
+       $(CL65) --cpu $1 -t none $(START) -o $$@ $$<
+
+$(WORKDIR)/$1-reass.s: $(WORKDIR)/$1-disass.bin
+       $(DA65) --cpu $1 $(START) -o $$@ $$<
+
+$(WORKDIR)/$1-reass.bin: $(WORKDIR)/$1-reass.s $(DIFF)
+       $(if $(QUIET),echo dasm/$1-reass.bin)
+       $(CL65) --cpu $1 -t none $(START) -o $$@ $$<
+       $(DIFF) $$@ $(WORKDIR)/$1-disass.bin
+
+endef # DISASS_template
+
+$(foreach cpu,$(CPUS),$(eval $(call DISASS_template,$(cpu))))
+
+clean:
+       @$(call RMDIR,$(WORKDIR))
+       @$(call DEL,$(SOURCES:.s=.o))
diff --git a/test/disassembler/4510-disass.s b/test/disassembler/4510-disass.s
deleted file mode 100644 (file)
index 96ed641..0000000
+++ /dev/null
@@ -1,298 +0,0 @@
-.setcpu "4510"
-
-ZP = $12
-ABS = $2345
-
-start:
-   brk
-   ora (ZP,x)
-   cle
-   see
-   tsb ZP
-   ora ZP
-   asl ZP
-   rmb0 ZP
-   php
-   ora #$01
-   asl
-   tsy
-   tsb ABS
-   ora ABS
-   asl ABS
-   bbr0 ZP,label1
-
-label1:
-   bpl label2
-   ora (ZP),y
-   ora (ZP),z
-   lbpl start ; bpl start
-   trb ZP
-   ora ZP,x
-   asl ZP,x
-   rmb1 ZP
-   clc
-   ora ABS,y
-   inc
-   inz
-   trb ABS
-   ora ABS,x
-   asl ABS,x
-   bbr1 ZP,label2
-
-label2:
-   jsr ABS
-   and (ZP,x)
-   jsr ($2345)
-   jsr ($2456,x)
-   bit ZP
-   and ZP
-   rol ZP
-   rmb2 ZP
-   plp
-   and #$01
-   rol
-   tys
-   bit ABS
-   and ABS
-   rol ABS
-   bbr2 ZP,label3
-
-label3:
-   bmi label4
-   and (ZP),y
-   and (ZP),z
-   lbmi start ; bmi start
-   bit ZP,x
-   and ZP,x
-   rol ZP,x
-   rmb3 ZP
-   sec
-   and ABS,y
-   dec
-   dez
-   bit ABS,x
-   and ABS,x
-   rol ABS,x
-   bbr3 ZP,label4
-
-label4:
-   rti
-   eor (ZP,x)
-   neg
-   asr
-   asr ZP
-   eor ZP
-   lsr ZP
-   rmb4 ZP
-   pha
-   eor #$01
-   lsr
-   taz
-   jmp ABS
-   eor ABS
-   lsr ABS
-   bbr4 ZP,label5
-
-label5:
-   bvc label6
-   eor (ZP),y
-   eor (ZP),z
-   lbvc start ; bvc start
-   asr ZP,x
-   eor ZP,x
-   lsr ZP,x
-   rmb5 ZP
-   cli
-   eor ABS,y
-   phy
-   tab
-   map
-   eor ABS,x
-   lsr ABS,x
-   bbr5 ZP,label6
-
-label6:
-   rts
-   adc (ZP,x)
-   rtn #$09
-   bsr start
-   stz ZP
-   adc ZP
-   ror ZP
-   rmb6 ZP
-   pla
-   adc #$01
-   ror
-   tza
-   jmp ($2345)
-   adc ABS
-   ror ABS
-   bbr6 ZP,label7
-
-label7:
-   bvs label8
-   adc (ZP),y
-   adc (ZP),z
-   lbvs start ; bvs start
-   stz ZP,x
-   adc ZP,x
-   ror ZP,x
-   rmb7 ZP
-   sei
-   adc ABS,y
-   ply
-   tba
-   jmp ($2456,x)
-   adc ABS,x
-   ror ABS,x
-   bbr7 ZP,label8
-
-label8:
-   bra label9
-   sta (ZP,x)
-   sta ($0f,sp),y
-   lbra start ; bra start
-   sty ZP
-   sta ZP
-   stx ZP
-   smb0 ZP
-   dey
-   bit #$01
-   txa
-   sty ABS,x
-   sty ABS
-   sta ABS
-   stx ABS
-   bbs0 ZP,label9
-
-label9:
-   bcc labelA
-   sta (ZP),y
-   sta (ZP),z
-   lbcc start ; bcc start
-   sty ZP,x
-   sta ZP,x
-   stx ZP,y
-   smb1 ZP
-   tya
-   sta ABS,y
-   txs
-   stx ABS,y
-   stz ABS
-   sta ABS,x
-   stz ABS,x
-   bbs1 ZP,labelA
-
-labelA:
-   ldy #$01
-   lda (ZP,x)
-   ldx #$01
-   ldz #$01
-   ldy ZP
-   lda ZP
-   ldx ZP
-   smb2 ZP
-   tay
-   lda #$01
-   tax
-   ldz ABS
-   ldy ABS
-   lda ABS
-   ldx ABS
-   bbs2 ZP,labelB
-
-labelB:
-   bcs labelC
-   lda (ZP),y
-   lda (ZP),z
-   lbcs start ; bcs start
-   ldy ZP,x
-   lda ZP,x
-   ldx ZP,y
-   smb3 ZP
-   clv
-   lda ABS,y
-   tsx
-   ldz ABS,x
-   ldy ABS,x
-   lda ABS,x
-   ldx ABS,y
-   bbs3 ZP,labelC
-
-labelC:
-   cpy #$01
-   cmp (ZP,x)
-   cpz #$01
-   dew ZP
-   cpy ZP
-   cmp ZP
-   dec ZP
-   smb4 ZP
-   iny
-   cmp #$01
-   dex
-   asw ABS
-   cpy ABS
-   cmp ABS
-   dec ABS
-   bbs4 ZP,labelD
-
-labelD:
-   bne labelE
-   cmp (ZP),y
-   cmp (ZP),z
-   lbne start ; bne start
-   cpz ZP
-   cmp ZP,x
-   dec ZP,x
-   smb5 ZP
-   cld
-   cmp ABS,y
-   phx
-   phz
-   cpz ABS
-   cmp ABS,x
-   dec ABS,x
-   bbs5 ZP,labelE
-
-labelE:
-   cpx #$01
-   sbc (ZP,x)
-   lda ($0f,sp),y
-   inw ZP
-   cpx ZP
-   sbc ZP
-   inc ZP
-   smb6 ZP
-   inx
-   sbc #$01
-   eom
-   nop
-   row ABS
-   cpx ABS
-   sbc ABS
-   inc ABS
-   bbs6 ZP,labelF
-
-labelF:
-   beq labelG
-   sbc (ZP),y
-   sbc (ZP),z
-   lbeq start ; beq start
-   phw #$089a
-   sbc ZP,x
-   inc ZP,x
-   smb7 ZP
-   sed
-   sbc ABS,y
-   plx
-   plz
-   phd ABS
-   phw ABS
-   sbc ABS,x
-   inc ABS,x
-   bbs7 ZP,labelG
-
-labelG:
-   brk
-
diff --git a/test/disassembler/Makefile b/test/disassembler/Makefile
deleted file mode 100644 (file)
index 2621b0c..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-
-# makefile for the disassembler regression tests
-
-BINDIR = ../../bin
-WORKDIR := ../../testwrk
-
-#BASE_TARGETS  = 6502 6502x 65sc02 65c02
-#BASE_TARGETS += 4510 huc6280
-BASE_TARGETS  = 4510
-
-START = --start-addr 0x8000
-
-DISASS_TARGETS = $(BASE_TARGETS)
-
-# default target defined later
-all:
-
-# generate opcode targets and expand target list
-define disass
-DISASS_TARGETLIST += $$(WORKDIR)/$(1)-reass.bin $$(WORKDIR)/$(1)-reass.s $$(WORKDIR)/$(1)-disass.bin
-
-$$(WORKDIR)/$(1)-disass.bin: $(1)-disass.s
-       @$$(BINDIR)/cl65 --cpu $(1) -t none $(START) --obj-path $$(WORKDIR) -o $$@ $$<
-       @rm -f $(1)-disass.o #workaround for #168
-
-$$(WORKDIR)/$(1)-reass.s: $$(WORKDIR)/$(1)-disass.bin
-       @$$(BINDIR)/da65 --cpu $(1) $(START) -o $$@ $$<
-
-$$(WORKDIR)/$(1)-reass.bin: $$(WORKDIR)/$(1)-reass.s
-       @$$(BINDIR)/cl65 --cpu $(1) -t none $(START) --obj-path $$(WORKDIR) -o $$@ $$<
-       @rm -f $(1)-reass.o #workaround for #168
-       @cmp $$@ $$(WORKDIR)/$(1)-disass.bin
-       @echo da65 --cpu $(1) ok
-endef
-$(foreach target,$(DISASS_TARGETS),$(eval $(call disass,$(target))))
-
-# now that all targets have been generated, get to the manual ones
-all: $(DISASS_TARGETLIST)
-       @#
-
-.PHONY: all $(DISASS_TARGETLIST)
-
index bc4226acbf04a7564ea81612dedef92e20924b3b..4b05ca5db63f47fd838bdfcca25e57febd207910 100644 (file)
@@ -1,29 +1,42 @@
-# makefile for the tests that MUST NOT compile
+# Makefile for the tests that MUST NOT compile
 
 ifneq ($(shell echo),)
-  CMD_EXE := 1
+  CMD_EXE = 1
 endif
 
 ifdef CMD_EXE
-  NOT := - # Hack
-  DEL = -del /f $(subst /,\,$1)
+  S = $(subst /,\,/)
+  NOT = - # Hack
+  NULLDEV = nul:
+  MKDIR = mkdir $(subst /,\,$1)
+  RMDIR = -rmdir /s /q $(subst /,\,$1)
 else
-  NOT := !
-  DEL = $(RM) $1
+  S = /
+  NOT = !
+  NULLDEV = /dev/null
+  MKDIR = mkdir -p $1
+  RMDIR = $(RM) -r $1
 endif
 
-CC65 := $(if $(wildcard ../../bin/cc65*),../../bin/cc65,cc65)
+ifdef QUIET
+  .SILENT:
+  NULLERR = 2>$(NULLDEV)
+endif
+
+CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65)
 
-WORKDIR := ../../testwrk
+WORKDIR = ../../testwrk/err
 
 .PHONY: all clean
 
-TESTS := $(patsubst %.c,$(WORKDIR)/%.s,$(wildcard *.c))
+SOURCES := $(wildcard *.c)
+TESTS = $(patsubst %.c,$(WORKDIR)/%.s,$(SOURCES))
 
 all: $(TESTS)
 
 $(WORKDIR)/%.s: %.c
-       $(NOT) $(CC65) -o $@ $<
+       $(if $(QUIET),echo err/$*.s)
+       $(NOT) $(CC65) -o $@ $< $(NULLERR)
 
 clean:
-       @$(call DEL,$(TESTS))
+       @$(call RMDIR,$(WORKDIR))
diff --git a/test/err/bss-name-conflict.c b/test/err/bss-name-conflict.c
new file mode 100644 (file)
index 0000000..1d6cd50
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+  !!DESCRIPTION!! conflicting bss-name pragmas
+  !!ORIGIN!!      cc65 regression tests
+  !!LICENCE!!     Public Domain
+  !!AUTHOR!!      Piotr Fusik
+*/
+
+/*
+  see: https://github.com/cc65/cc65/issues/409
+*/
+
+char oam_off;
+#pragma bss-name (push,"ZEROPAGE")
+char oam_off;
+#pragma bss-name (pop)
+
+int main(void)
+{
+    return 0;
+}
diff --git a/test/err/duplicate-global-static.c b/test/err/duplicate-global-static.c
new file mode 100644 (file)
index 0000000..6aa27f5
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+  !!DESCRIPTION!! global duplicated with static variable
+  !!ORIGIN!!      cc65 regression tests
+  !!LICENCE!!     Public Domain
+  !!AUTHOR!!      Piotr Fusik
+*/
+
+/*
+  see: https://github.com/cc65/cc65/issues/191
+*/
+
+int n = 0;
+static int n = 0;           /* should give an error */
+
+int main(void)
+{
+    return n;
+}
diff --git a/test/err/duplicate-global.c b/test/err/duplicate-global.c
new file mode 100644 (file)
index 0000000..bd4fcc2
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+  !!DESCRIPTION!! duplicate globals
+  !!ORIGIN!!      cc65 regression tests
+  !!LICENCE!!     Public Domain
+  !!AUTHOR!!      Piotr Fusik
+*/
+
+/*
+  see: https://github.com/cc65/cc65/issues/191
+*/
+
+#pragma warn(error, on)
+
+int n = 0;
+int n = 0;           /* should give an error */
+
+int main(void)
+{
+    return n;
+}
diff --git a/test/err/duplicate-static-global.c b/test/err/duplicate-static-global.c
new file mode 100644 (file)
index 0000000..6e5e70a
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+  !!DESCRIPTION!! static duplicated with global variable
+  !!ORIGIN!!      cc65 regression tests
+  !!LICENCE!!     Public Domain
+  !!AUTHOR!!      Piotr Fusik
+*/
+
+/*
+  see: https://github.com/cc65/cc65/issues/191
+*/
+
+static int n = 0;
+int n = 0;           /* should give an error */
+
+int main(void)
+{
+    return n;
+}
diff --git a/test/err/duplicate-static.c b/test/err/duplicate-static.c
new file mode 100644 (file)
index 0000000..394cc1e
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+  !!DESCRIPTION!! duplicate static variables
+  !!ORIGIN!!      cc65 regression tests
+  !!LICENCE!!     Public Domain
+  !!AUTHOR!!      Piotr Fusik
+*/
+
+/*
+  see: https://github.com/cc65/cc65/issues/191
+*/
+
+#pragma warn(error, on)
+
+static int n = 0;
+static int n = 0;           /* should give an error */
+
+int main(void)
+{
+    return n;
+}
diff --git a/test/err/void-empty.c b/test/err/void-empty.c
new file mode 100644 (file)
index 0000000..9009182
--- /dev/null
@@ -0,0 +1,9 @@
+/*
+  !!DESCRIPTION!! Uninitialized void variables
+  !!ORIGIN!!      cc65 regression tests
+  !!LICENCE!!     Public Domain
+  !!AUTHOR!!      Greg King
+*/
+
+void test;
+const void list;
diff --git a/test/err/void-size2.c b/test/err/void-size2.c
new file mode 100644 (file)
index 0000000..3d4f133
--- /dev/null
@@ -0,0 +1,11 @@
+/*
+  !!DESCRIPTION!! Size of void cast
+  !!ORIGIN!!      cc65 regression tests
+  !!LICENCE!!     Public Domain
+  !!AUTHOR!!      Greg King
+*/
+
+unsigned test (void)
+{
+    return sizeof ((void)12345);
+}
index 918316c6c852daf1614f2a66be71bd7d7581dc66..330c9d5004e38319ab6d515e017736ed810ef400 100644 (file)
@@ -1,63 +1,96 @@
-
-# makefile for the remaining tests that need special care in one way or another
+# Makefile for the remaining tests that need special care in one way or another
 
 ifneq ($(shell echo),)
-  CMD_EXE := 1
+  CMD_EXE = 1
 endif
 
 ifdef CMD_EXE
-  S := $(subst /,\,/)
-  NOT := - # Hack
-  DEL = -del /f $(subst /,\,$1)
+  S = $(subst /,\,/)
+  NOT = - # Hack
+  EXE = .exe
+  NULLDEV = nul:
+  MKDIR = mkdir $(subst /,\,$1)
+  RMDIR = -rmdir /s /q $(subst /,\,$1)
+  DEL = del /f $(subst /,\,$1)
 else
-  S := /
-  NOT := !
+  S = /
+  NOT = !
+  EXE =
+  NULLDEV = /dev/null
+  MKDIR = mkdir -p $1
+  RMDIR = $(RM) -r $1
   DEL = $(RM) $1
 endif
 
-CC65FLAGS := -t sim6502
-SIM65FLAGS := -x 200000000
+ifdef QUIET
+  .SILENT:
+  NULLOUT = >$(NULLDEV)
+  NULLERR = 2>$(NULLDEV)
+endif
+
+SIM65FLAGS = -x 200000000
 
-CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
+CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65)
 SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)
 
-WORKDIR := ..$S..$Stestwrk
-DIFF := $(WORKDIR)/bdiff
+WORKDIR = ..$S..$Stestwrk$Smisc
+
+OPTIONS = g O Os Osi Osir Osr Oi Oir Or
+
+DIFF = $(WORKDIR)$Sbdiff$(EXE)
+
+CC = gcc
+CFLAGS = -O2
 
 .PHONY: all clean
 
 SOURCES := $(wildcard *.c)
-TESTS := $(foreach option,. .o. .os. .osi. .osir. .oi. .oir. .or.,$(SOURCES:%.c=$(WORKDIR)/%$(option)prg))
+TESTS  = $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).6502.prg))
+TESTS += $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).65c02.prg))
 
 all: $(TESTS)
 
+$(WORKDIR):
+       $(call MKDIR,$(WORKDIR))
+
+$(DIFF): ../bdiff.c | $(WORKDIR)
+       $(CC) $(CFLAGS) -o $@ $<
+
+define PRG_template
+
 # should compile, but then hangs in an endless loop
-$(WORKDIR)/endless%prg: endless.c
-       $(CL65) $(subst .,,$(*:.o%=-O%)) $(CC65FLAGS) $< -o $@
-       $(NOT) $(SIM65) $(SIM65FLAGS) $@
+$(WORKDIR)/endless.$1.$2.prg: endless.c | $(WORKDIR)
+       $(if $(QUIET),echo misc/endless.$1.$2.prg)
+       $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
+       $(NOT) $(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) $(NULLERR)
 
 # these need reference data that can't be generated by a host-compiled program,
 # in a useful way
-$(WORKDIR)/limits%prg: limits.c
-       $(CL65) $(subst .,,$(*:.o%=-O%)) $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/limits.out
-       $(DIFF) $(WORKDIR)/limits.out limits.ref
+$(WORKDIR)/limits.$1.$2.prg: limits.c $(DIFF)
+       $(if $(QUIET),echo misc/limits.$1.$2.prg)
+       $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
+       $(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/limits.$1.out
+       $(DIFF) $(WORKDIR)/limits.$1.out limits.ref
 
 # the rest are tests that fail currently for one reason or another
-$(WORKDIR)/fields%prg: fields.c
-       @echo "FIXME: " $@ "currently will fail."
-       $(CL65) $(subst .,,$(*:.o%=-O%)) $(CC65FLAGS) $< -o $@
-       -$(SIM65) $(SIM65FLAGS) $@
-$(WORKDIR)/sitest%prg: sitest.c
-       @echo "FIXME: " $@ "currently will fail."
-       -$(CL65) $(subst .,,$(*:.o%=-O%)) $(CC65FLAGS) $< -o $@
-#      -$(SIM65) $(SIM65FLAGS) $@
-$(WORKDIR)/cc65141011%prg: cc65141011.c
-       @echo "FIXME: " $@ "currently can fail."
-       $(CL65) $(subst .,,$(*:.o%=-O%)) $(CC65FLAGS) $< -o $@
-       -$(SIM65) $(SIM65FLAGS) $@
+$(WORKDIR)/fields.$1.$2.prg: fields.c | $(WORKDIR)
+       @echo "FIXME: " $$@ "currently will fail."
+       $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
+       -$(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT)
+$(WORKDIR)/sitest.$1.$2.prg: sitest.c | $(WORKDIR)
+       @echo "FIXME: " $$@ "currently will fail."
+       -$(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
+#      -$(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT)
+$(WORKDIR)/cc65141011.$1.$2.prg: cc65141011.c | $(WORKDIR)
+       @echo "FIXME: " $$@ "currently can fail."
+       $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
+       -$(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT)
+
+endef # PRG_template
+
+$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),6502)))
+$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02)))
 
 clean:
-       @$(call DEL,$(TESTS))
+       @$(call RMDIR,$(WORKDIR))
        @$(call DEL,$(SOURCES:.c=.o))
-       @$(call DEL,$(SOURCES:%.c=$(WORKDIR)/%.out))
index 09dd96d4425455f290c50a165751835c50d64576..3c2e582e4686e73ae50b85233d11b1aa675ea85a 100644 (file)
@@ -1,96 +1,94 @@
-
-# makefile for the regression tests that generate output which has to be
+# Makefile for the regression tests that generate output which has to be
 # compared with reference output
 
 ifneq ($(shell echo),)
-  CMD_EXE := 1
+  CMD_EXE = 1
 endif
 
 ifdef CMD_EXE
-  S := $(subst /,\,/)
-  DEL = -del /f $(subst /,\,$1)
+  S = $(subst /,\,/)
+  EXE = .exe
+  NULLDEV = nul:
+  MKDIR = mkdir $(subst /,\,$1)
+  RMDIR = -rmdir /s /q $(subst /,\,$1)
+  DEL = del /f $(subst /,\,$1)
 else
-  S := /
+  S = /
+  EXE =
+  NULLDEV = /dev/null
+  MKDIR = mkdir -p $1
+  RMDIR = $(RM) -r $1
   DEL = $(RM) $1
 endif
 
-CC65FLAGS := -t sim6502
-SIM65FLAGS := -x 200000000
+ifdef QUIET
+  .SILENT:
+  NULLERR = 2>$(NULLDEV)
+endif
+
+SIM65FLAGS = -x 200000000
 
-CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
+CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65)
 SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)
 
-WORKDIR := ..$S..$Stestwrk
-DIFF := $(WORKDIR)/bdiff
+WORKDIR = ..$S..$Stestwrk$Sref
+
+OPTIONS = g O Os Osi Osir Osr Oi Oir Or
 
-CC := gcc
-CFLAGS := -O2 -Wall -W -Wextra -fwrapv -fno-strict-overflow
+DIFF = $(WORKDIR)$Sbdiff$(EXE)
+
+CC = gcc
+CFLAGS = -O2 -Wall -W -Wextra -funsigned-char -fwrapv -fno-strict-overflow
 
 .PHONY: all clean
 
 SOURCES := $(wildcard *.c)
-REFS := $(SOURCES:%.c=$(WORKDIR)/%.ref)
-TESTS := $(foreach option,. .o. .os. .osi. .osir. .oi. .oir. .or.,$(SOURCES:%.c=$(WORKDIR)/%$(option)prg))
+REFS = $(SOURCES:%.c=$(WORKDIR)/%.ref)
+TESTS  = $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).6502.prg))
+TESTS += $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).65c02.prg))
 
 all: $(REFS) $(TESTS)
 
-$(WORKDIR)/%.ref: %.c
-       $(CC) $(CFLAGS) $< -o $(WORKDIR)/$*.host
+$(WORKDIR):
+       $(call MKDIR,$(WORKDIR))
+
+$(WORKDIR)/%.ref: %.c | $(WORKDIR)
+       $(if $(QUIET),echo ref/$*.host)
+       $(CC) $(CFLAGS) -o $(WORKDIR)/$*.host $< $(NULLERR)
        $(WORKDIR)$S$*.host > $@
 
+$(DIFF): ../bdiff.c | $(WORKDIR)
+       $(CC) $(CFLAGS) -o $@ $<
+
 # Some files have "K & R"-style syntax.  Therefore, some forward
 # function-declarations don't match the later function definitions.
 # Those programs fail when fastcall is used; but, the cdecl calling convention
 # tolerates those conflicts.  Therefore, make their functions default to cdecl.
 #
-$(WORKDIR)/init%prg: CC65FLAGS += -Wc --all-cdecl
-$(WORKDIR)/switch.%rg: CC65FLAGS += -Wc --all-cdecl
-$(WORKDIR)/yacc.%rg: CC65FLAGS += -Wc --all-cdecl
-$(WORKDIR)/yaccdbg%prg: CC65FLAGS += -Wc --all-cdecl
-
-$(WORKDIR)/%.prg: %.c $(WORKDIR)/%.ref
-       $(CL65) $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
-       $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
-
-$(WORKDIR)/%.o.prg: %.c $(WORKDIR)/%.ref
-       $(CL65) -O $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
-       $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
-
-$(WORKDIR)/%.os.prg: %.c $(WORKDIR)/%.ref
-       $(CL65) -Os $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
-       $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
-
-$(WORKDIR)/%.osi.prg: %.c $(WORKDIR)/%.ref
-       $(CL65) -Osi $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
-       $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
-
-$(WORKDIR)/%.osir.prg: %.c $(WORKDIR)/%.ref
-       $(CL65) -Osir $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
-       $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
-
-$(WORKDIR)/%.oi.prg: %.c $(WORKDIR)/%.ref
-       $(CL65) -Oi $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
-       $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
-
-$(WORKDIR)/%.oir.prg: %.c $(WORKDIR)/%.ref
-       $(CL65) -Oir $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
-       $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
-
-$(WORKDIR)/%.or.prg: %.c $(WORKDIR)/%.ref
-       $(CL65) -Or $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
-       $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
+$(WORKDIR)/init.%.prg   \
+$(WORKDIR)/switch.%.prg \
+$(WORKDIR)/yacc.%.prg   \
+$(WORKDIR)/yaccdbg.%.prg: CC65FLAGS += -Wc --all-cdecl
+
+# "yaccdbg.c" includes "yacc.c".
+# yaccdbg's built files must depend on both of them.
+#
+$(WORKDIR)/yaccdbg.ref:   yacc.c
+$(WORKDIR)/yaccdbg.%.prg: yacc.c
+
+define PRG_template
+
+$(WORKDIR)/%.$1.$2.prg: %.c $(WORKDIR)/%.ref $(DIFF)
+       $(if $(QUIET),echo ref/$$*.$1.$2.prg)
+       $(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< $(NULLERR)
+       $(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/$$*.out
+       $(DIFF) $(WORKDIR)/$$*.out $(WORKDIR)/$$*.ref
+
+endef # PRG_template
+
+$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),6502)))
+$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02)))
 
 clean:
-       @$(call DEL,$(TESTS))
+       @$(call RMDIR,$(WORKDIR))
        @$(call DEL,$(SOURCES:.c=.o))
-       @$(call DEL,$(SOURCES:%.c=$(WORKDIR)/%.out))
-       @$(call DEL,$(SOURCES:%.c=$(WORKDIR)/%.ref))
-       @$(call DEL,$(SOURCES:%.c=$(WORKDIR)/%.host))
index 68a0198e161ee37b4f976adfa32b6c5c6fad9c24..8fcc951a6ee2f44b07ec63564e9103b8282048fb 100644 (file)
@@ -1,38 +1,38 @@
-/*\r
-  !!DESCRIPTION!! div/mod test\r
-  !!ORIGIN!!\r
-  !!LICENCE!!     public domain\r
-*/\r
-\r
-#include <stdio.h>\r
-\r
-void printc(signed char a,signed char b){\r
-signed char x=a/b,y=a%b,z=a*b;\r
-       printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z);\r
-}\r
-void prints(short a,short b){\r
-short x=a/b,y=a%b,z=a*b;\r
-       printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z);\r
-}\r
-void printl(long a,long b){\r
-long x=a/b,y=a%b,z=a*b;\r
-       printf("%3ld,%3ld is %3ld,%3ld,%3ld\n",a,b,x,y,z);\r
-}\r
-\r
-int main(void) {\r
-       printl( 3,-2);\r
-       printl(-3,-2);\r
-       printl(-3, 2);\r
-       printl( 3, 2);\r
-       printf("-\n");\r
-       prints( 3,-2);\r
-       prints(-3,-2);\r
-       prints(-3, 2);\r
-       prints( 3, 2);\r
-       printf("-\n");\r
-       printc( 3,-2);\r
-       printc(-3,-2);\r
-       printc(-3, 2);\r
-       printc( 3, 2);\r
+/*
+  !!DESCRIPTION!! div/mod test
+  !!ORIGIN!!
+  !!LICENCE!!     public domain
+*/
+
+#include <stdio.h>
+
+void printc(signed char a,signed char b){
+signed char x=a/b,y=a%b,z=a*b;
+       printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z);
+}
+void prints(short a,short b){
+short x=a/b,y=a%b,z=a*b;
+       printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z);
+}
+void printl(long a,long b){
+long x=a/b,y=a%b,z=a*b;
+       printf("%3ld,%3ld is %3ld,%3ld,%3ld\n",a,b,x,y,z);
+}
+
+int main(void) {
+       printl( 3,-2);
+       printl(-3,-2);
+       printl(-3, 2);
+       printl( 3, 2);
+       printf("-\n");
+       prints( 3,-2);
+       prints(-3,-2);
+       prints(-3, 2);
+       prints( 3, 2);
+       printf("-\n");
+       printc( 3,-2);
+       printc(-3,-2);
+       printc(-3, 2);
+       printc( 3, 2);
        return 0;
-}\r
+}
index 5a581675318dc39af59782ce50ee09a94b810d9f..44cd544fd77d5128c5423278bd20d05041f854e7 100644 (file)
@@ -1,95 +1,95 @@
-/*\r
-  !!DESCRIPTION!! variable initialization\r
-  !!ORIGIN!!      LCC 4.1 Testsuite\r
-  !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC\r
-*/\r
-\r
-#include "common.h"\r
-/* todo: add back conditional stuff here ! */\r
-\r
-typedef struct { int codes[3]; char name[6]; } Word;\r
-\r
-#ifdef NO_IMPLICIT_FUNC_PROTOTYPES\r
-\r
-#ifdef NO_OLD_FUNC_DECL\r
-f();\r
-void g(Word *p);\r
-h();\r
-#else\r
-f();\r
-g();\r
-h();\r
-#endif\r
-\r
-#endif\r
-\r
-/*\r
-Word words[] = {\r
-        1, 2, 3,"if",\r
-       { { 4, 5 }, { 'f', 'o', 'r' } },\r
-        6, 7, 8, {"else"},\r
-        { { 9, 10, 11,}, 'w', 'h', 'i', 'l', 'e', },\r
-        { 0 },\r
-}, *wordlist = words;\r
-*/\r
-\r
-Word words[] = {\r
-        {{1, 2, 3},"if"},\r
-       { { 4, 5 }, { 'f', 'o', 'r' } },\r
-        {{6, 7, 8}, "else"},\r
-        { { 9, 10, 11}, {'w', 'h', 'i', 'l', 'e', }},\r
-        {{ 0 }},\r
-}, *wordlist = words;\r
-\r
-/*int x[][5] = { 1, 2, 3, 4, 0, { 5, 6 }, { 7 } };*/\r
-int x[][5] = { {1, 2, 3, 4, 0 }, { 5, 6 }, { 7 } };\r
-int *y[] = { x[0], x[1], x[2], 0 };\r
-\r
-main()\r
-{\r
-       int i, j;\r
-\r
-       for (i = 0; y[i]; i++) {\r
-               for (j = 0; y[i][j]; j++)\r
-                       printf(" %d", y[i][j]);\r
-               printf("\n");\r
-       }\r
-       f();\r
-       g(wordlist);\r
-       return 0;\r
-}\r
-\r
-f() {\r
-       static char *keywords[] = {"if", "for", "else", "while", 0, };\r
-       char **p;\r
-\r
-       for (p = keywords; *p; p++)\r
-               printf("%s\n", *p);\r
-}\r
-\r
-#ifdef NO_OLD_FUNC_DECL\r
-void g(Word *p)\r
-#else\r
-g(p)\r
-Word *p;\r
-#endif\r
-{\r
-       int i;\r
-\r
-       for ( ; p->codes[0]; p++) {\r
-               for (i = 0; i < sizeof p->codes/sizeof(p->codes[0]); i++)\r
-                       printf("%d ", p->codes[i]);\r
-               printf("%s\n", p->name);\r
-       }\r
-       h();\r
-}\r
-\r
-h()\r
-{\r
-       int i;\r
-\r
-       for (i = 0; i < sizeof(words)/sizeof(Word); i++)\r
-               printf("%d %d %d %s\n", words[i].codes[0],\r
-                       words[i].codes[1], words[i].codes[2],\r
-                       &words[i].name[0]);\r
-}\r
+/*
+  !!DESCRIPTION!! variable initialization
+  !!ORIGIN!!      LCC 4.1 Testsuite
+  !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
+*/
+
+#include "common.h"
+/* todo: add back conditional stuff here ! */
+
+typedef struct { int codes[3]; char name[6]; } Word;
+
+#ifdef NO_IMPLICIT_FUNC_PROTOTYPES
+
+#ifdef NO_OLD_FUNC_DECL
+f();
+void g(Word *p);
+h();
+#else
+f();
+g();
+h();
+#endif
+
+#endif
+
+/*
+Word words[] = {
+        1, 2, 3,"if",
+       { { 4, 5 }, { 'f', 'o', 'r' } },
+        6, 7, 8, {"else"},
+        { { 9, 10, 11,}, 'w', 'h', 'i', 'l', 'e', },
+        { 0 },
+}, *wordlist = words;
+*/
+
+Word words[] = {
+        {{1, 2, 3},"if"},
+       { { 4, 5 }, { 'f', 'o', 'r' } },
+        {{6, 7, 8}, "else"},
+        { { 9, 10, 11}, {'w', 'h', 'i', 'l', 'e', }},
+        {{ 0 }},
+}, *wordlist = words;
+
+/*int x[][5] = { 1, 2, 3, 4, 0, { 5, 6 }, { 7 } };*/
+int x[][5] = { {1, 2, 3, 4, 0 }, { 5, 6 }, { 7 } };
+int *y[] = { x[0], x[1], x[2], 0 };
+
+main()
+{
+       int i, j;
+
+       for (i = 0; y[i]; i++) {
+               for (j = 0; y[i][j]; j++)
+                       printf(" %d", y[i][j]);
+               printf("\n");
+       }
+       f();
+       g(wordlist);
+       return 0;
+}
+
+f() {
+       static char *keywords[] = {"if", "for", "else", "while", 0, };
+       char **p;
+
+       for (p = keywords; *p; p++)
+               printf("%s\n", *p);
+}
+
+#ifdef NO_OLD_FUNC_DECL
+void g(Word *p)
+#else
+g(p)
+Word *p;
+#endif
+{
+       int i;
+
+       for ( ; p->codes[0]; p++) {
+               for (i = 0; i < sizeof p->codes/sizeof(p->codes[0]); i++)
+                       printf("%d ", p->codes[i]);
+               printf("%s\n", p->name);
+       }
+       h();
+}
+
+h()
+{
+       int i;
+
+       for (i = 0; i < sizeof(words)/sizeof(Word); i++)
+               printf("%d %d %d %s\n", words[i].codes[0],
+                       words[i].codes[1], words[i].codes[2],
+                       &words[i].name[0]);
+}
index d8c064ef3fbbfc36991fb4dbe36c3d6ef45273a0..29f9e3de40ac27327a646be5d5341bff02691f38 100644 (file)
-/*\r
-  !!DESCRIPTION!! pointer test\r
-  !!ORIGIN!!\r
-  !!LICENCE!!     public domain\r
-*/\r
-\r
-#include "common.h"\r
-#include <stdio.h>\r
-\r
-/*\r
-  check behaviour on incompletely declared arrays\r
-*/\r
-\r
-char i1[];\r
-\r
-void test1(void) {\r
-int a;\r
-\r
-       a=sizeof(i1[0]);\r
-       printf("%04x - ",a);\r
-       if(sizeof(i1[0])==sizeof(char)) {\r
-               /* gcc gives size of element */\r
-               printf("sizeof(i1[0]) gives size of element\n");\r
-       }\r
-       if(sizeof(i1[0])==sizeof(char*)) {\r
-               printf("sizeof(i1[0]) gives size of pointer to element\n");\r
-       }\r
-}\r
-\r
-/*\r
-  check behaviour on string init\r
-*/\r
-\r
-char t1[]="abcde";\r
-char t2[]={"abcde"};\r
-\r
-char *t3="abcde";\r
-char *t4={"abcde"};\r
-\r
-void test2(void) {\r
-char c1,c2,c3,c4;\r
-int i,e=0;\r
-       for(i=0;i<5;i++){\r
-               c1=t1[i];c2=t2[i];c3=t3[i];c4=t4[i];\r
-/*             printf("%02x %02x %02x %02x\n",c1,c2,c3,c4); */\r
-               printf("%c %c %c %c\n",c1,c2,c3,c4);\r
-               if(!((c1==c2)&(c1==c3)&(c1==c4))) e=1;\r
-       }\r
-       if(e) printf("test2 failed.\n");\r
-       else printf("test2 ok.\n");\r
-}\r
-\r
-/*\r
-  check behaviour on extern-declarations inside functions\r
-*/\r
-\r
-typedef struct {\r
-  char *name;\r
-  void *func;\r
-} A3;\r
-\r
-#ifdef NO_SLOPPY_STRUCT_INIT\r
-A3 a3[] = {\r
-  { "test3", (void*) NULL },\r
-  { "test3", (void*) NULL },\r
-};\r
-#else\r
-/*gcc warning: missing braces around initializer (near initialization for `a3[0]')\r
-  this type of struct-initialization seems to be kinda common */\r
-A3 a3[] = {\r
-    "test3", (void*) NULL  ,\r
-    "test3", (void*) NULL  ,\r
-};\r
-#endif\r
-\r
-void test3a(A3 *list, int number){\r
-       printf("%s %d\n",list->name,number);\r
-}\r
-\r
-static void test31(void)\r
-{\r
-    extern A3 a3[];\r
-    test3a(a3, -1);\r
-}\r
-\r
-#if 0\r
-/* this variation compiles and works with cc65, but gives an error with gcc :=P */\r
-static void test32(void)\r
-{\r
-    extern A3 *a3;\r
-    test3a(a3, -1);\r
-}\r
-#endif\r
-\r
-static void test30(void)\r
-{\r
-    test3a(a3, -1);\r
-}\r
-\r
-/*\r
-  todo: add test on function pointers in the form of (*func)(arg) ...\r
-  cc65 seems to have problems here aswell ;/\r
-*/\r
-\r
-int main(void) {\r
-       test1();\r
-       test2();\r
-       test30();\r
-       test31();\r
-/*     test32(); */\r
-       return 0;\r
-}\r
+/*
+  !!DESCRIPTION!! pointer test
+  !!ORIGIN!!
+  !!LICENCE!!     public domain
+*/
+
+#include "common.h"
+#include <stdio.h>
+
+/*
+  check behaviour on incompletely declared arrays
+*/
+
+char i1[];
+
+void test1(void) {
+int a;
+
+       a=sizeof(i1[0]);
+       printf("%04x - ",a);
+       if(sizeof(i1[0])==sizeof(char)) {
+               /* gcc gives size of element */
+               printf("sizeof(i1[0]) gives size of element\n");
+       }
+       if(sizeof(i1[0])==sizeof(char*)) {
+               printf("sizeof(i1[0]) gives size of pointer to element\n");
+       }
+}
+
+/*
+  check behaviour on string init
+*/
+
+char t1[]="abcde";
+char t2[]={"abcde"};
+
+char *t3="abcde";
+char *t4={"abcde"};
+
+void test2(void) {
+char c1,c2,c3,c4;
+int i,e=0;
+       for(i=0;i<5;i++){
+               c1=t1[i];c2=t2[i];c3=t3[i];c4=t4[i];
+/*             printf("%02x %02x %02x %02x\n",c1,c2,c3,c4); */
+               printf("%c %c %c %c\n",c1,c2,c3,c4);
+               if(!((c1==c2)&(c1==c3)&(c1==c4))) e=1;
+       }
+       if(e) printf("test2 failed.\n");
+       else printf("test2 ok.\n");
+}
+
+/*
+  check behaviour on extern-declarations inside functions
+*/
+
+typedef struct {
+  char *name;
+  void *func;
+} A3;
+
+#ifdef NO_SLOPPY_STRUCT_INIT
+A3 a3[] = {
+  { "test3", (void*) NULL },
+  { "test3", (void*) NULL },
+};
+#else
+/*gcc warning: missing braces around initializer (near initialization for `a3[0]')
+  this type of struct-initialization seems to be kinda common */
+A3 a3[] = {
+    "test3", (void*) NULL  ,
+    "test3", (void*) NULL  ,
+};
+#endif
+
+void test3a(A3 *list, int number){
+       printf("%s %d\n",list->name,number);
+}
+
+static void test31(void)
+{
+    extern A3 a3[];
+    test3a(a3, -1);
+}
+
+#if 0
+/* this variation compiles and works with cc65, but gives an error with gcc :=P */
+static void test32(void)
+{
+    extern A3 *a3;
+    test3a(a3, -1);
+}
+#endif
+
+static void test30(void)
+{
+    test3a(a3, -1);
+}
+
+/*
+  todo: add test on function pointers in the form of (*func)(arg) ...
+  cc65 seems to have problems here aswell ;/
+*/
+
+int main(void) {
+       test1();
+       test2();
+       test30();
+       test31();
+/*     test32(); */
+       return 0;
+}
index e75cfe71efa6c957c3fe7c3d2d71b7f4f65201a9..7a9bcecd7b820fc14807a324ef5427d5261d4519 100644 (file)
-/*\r
-  !!DESCRIPTION!! switch test\r
-  !!ORIGIN!!\r
-  !!LICENCE!!     public domain\r
-*/\r
-\r
-/*#define STANDALONE*/\r
-\r
-#include <stdio.h>\r
-\r
+/*
+  !!DESCRIPTION!! switch test
+  !!ORIGIN!!
+  !!LICENCE!!     public domain
+*/
+
+/*#define STANDALONE*/
+
+#include <stdio.h>
+
 void testlimits(int i) {
-       printf("%d:",i);\r
-\r
+       printf("%d:",i);
+
        switch(i) {
-               case -1:        /* works */\r
-               /* case 0xffff: */ /* 'range error' (-1) */\r
-\r
-                       printf("-1\n");\r
-                       break;\r
-               /* max int */\r
-\r
-/*              case 0x7fff:   */         /* works */\r
-               case 32767:                /* works */\r
-               /* case 32768: */          /* 'range error' (correct for that one!) */\r
-\r
-                       printf("max\n");\r
-                       break;\r
-               /* min int */\r
-\r
-               case -32768:               /* 'warning. constant is long' */\r
-               /* case 0x8000: */             /* 'range error' */\r
-               /* case -32769: */         /* 'range error' (correct for that one!) */\r
-                       printf("min\n");\r
-                       break;\r
-       }\r
-       printf("\n");\r
-}\r
-\r
-void testdefault1(unsigned char i) {\r
-/* we want a signed char */\r
-#ifdef REFCC\r
-\r
-#ifdef REFCC_UNSIGNED_CHARS\r
-signed char k;\r
-#else\r
-char k;\r
-#endif\r
-       \r
-#else\r
-       \r
-#ifdef UNSIGNED_CHARS\r
-signed char k;\r
-#else\r
-char k;\r
-#endif\r
-\r
-#endif\r
-\r
-       for(;i<254;) {\r
-               k = i;\r
-               printf(">%d\n",i);i++;\r
-               switch(k) {\r
-               case 1:\r
-                       break;\r
-               case 2:\r
-                       break;\r
-               case 3:\r
-                       break;\r
-               case 4:\r
-                       break;\r
-               case 5:\r
-                       break;\r
-               case 6:\r
-                       break;\r
-               case 7:\r
-                       break;\r
-               case 8:\r
-                       break;\r
-               case 9:\r
-                       break;\r
-               case 10:\r
-                       break;\r
-               case 11:\r
-                       break;\r
-               case 12:\r
-                       break;\r
-               case 13:\r
-                       break;\r
-               case 14:\r
-                       break;\r
-               case 15:\r
-                       break;\r
-               case 17:\r
-                       break;\r
-               /* triggers bug ? */\r
-               /* gcc warning: case label value exceeds maximum value for type */\r
-               /* cc65 error: range error */\r
-\r
-               /*\r
-               case 170:\r
-                       break;\r
-               */\r
-               case 18:\r
-                       break;\r
-               case 19:\r
-                       break;\r
-               case 20:\r
-                       break;\r
-               case 21:\r
-                       break;\r
-               case 22:\r
-                       break;\r
-               case 23:\r
-                       break;\r
-               case 24:\r
-                       switch(k) {\r
-                               case 1:\r
-                                       break;\r
-                               case 2:\r
-                                       break;\r
-                               case 3:\r
-                                       break;\r
-                               case 4:\r
-                               case 5:\r
-                               break;\r
-                               case 6:\r
-                               case 7:\r
-                                       break;\r
-                               case 8:\r
-                               case 9:\r
-                                       break;\r
-                               }\r
-                       break;\r
-               case 100:\r
-                       break;\r
-               default:\r
-                       printf(">>>default\n");\r
-                       /* triggers bug if this break; is missing? */\r
-                       /* break; */\r
-               }\r
-       }\r
-}\r
-\r
-void testdefault2(unsigned char i) {\r
-/* we want a unsigned char */\r
-#ifdef REFCC\r
-\r
-#ifdef REFCC_UNSIGNED_CHARS\r
-char k;\r
-#else\r
-unsigned char k;\r
-#endif\r
-       \r
-#else\r
-       \r
-#ifdef UNSIGNED_CHARS\r
-char k;\r
-#else\r
-unsigned char k;\r
-#endif\r
-\r
-#endif\r
-\r
-       for(;i<254;) {\r
-               k = i;\r
-               printf(">%d\n",i);i++;\r
-               switch(k) {\r
-               case 1:\r
-                       break;\r
-               case 2:\r
-                       break;\r
-               case 3:\r
-                       break;\r
-               case 4:\r
-                       break;\r
-               case 5:\r
-                       break;\r
-               case 6:\r
-                       break;\r
-               case 7:\r
-                       break;\r
-               case 8:\r
-                       break;\r
-               case 9:\r
-                       break;\r
-               case 10:\r
-                       break;\r
-               case 11:\r
-                       break;\r
-               case 12:\r
-                       break;\r
-               case 13:\r
-                       break;\r
-               case 14:\r
-                       break;\r
-               case 15:\r
-                       break;\r
-               case 17:\r
-                       break;\r
-               /* triggers bug ? */\r
-\r
-               case 170:\r
-                       break;\r
-               \r
-               case 18:\r
-                       break;\r
-               case 19:\r
-                       break;\r
-               case 20:\r
-                       break;\r
-               case 21:\r
-                       break;\r
-               case 22:\r
-                       break;\r
-               case 23:\r
-                       break;\r
-               case 24:\r
-                       switch(k) {\r
-                               case 1:\r
-                                       break;\r
-                               case 2:\r
-                                       break;\r
-                               case 3:\r
-                                       break;\r
-                               case 4:\r
-                               case 5:\r
-                               break;\r
-                               case 6:\r
-                               case 7:\r
-                                       break;\r
-                               case 8:\r
-                               case 9:\r
-                                       break;\r
-                               }\r
-                       break;\r
-               case 100:\r
-                       break;\r
-               default:\r
-                       printf(">>>default\n");\r
-                       /* triggers bug if this break; is missing? */\r
-                       /* break; */\r
-               }\r
-       }\r
+               case -1:        /* works */
+               /* case 0xffff: */ /* 'range error' (-1) */
+
+                       printf("-1\n");
+                       break;
+               /* max int */
+
+/*              case 0x7fff:   */         /* works */
+               case 32767:                /* works */
+               /* case 32768: */          /* 'range error' (correct for that one!) */
+
+                       printf("max\n");
+                       break;
+               /* min int */
+
+               case -32768:               /* 'warning. constant is long' */
+               /* case 0x8000: */             /* 'range error' */
+               /* case -32769: */         /* 'range error' (correct for that one!) */
+                       printf("min\n");
+                       break;
+       }
+       printf("\n");
+}
+
+void testdefault1(unsigned char i) {
+/* we want a signed char */
+#ifdef REFCC
+
+#ifdef REFCC_UNSIGNED_CHARS
+signed char k;
+#else
+char k;
+#endif
+       
+#else
+       
+#ifdef UNSIGNED_CHARS
+signed char k;
+#else
+char k;
+#endif
+
+#endif
+
+       for(;i<254;) {
+               k = i;
+               printf(">%d\n",i);i++;
+               switch(k) {
+               case 1:
+                       break;
+               case 2:
+                       break;
+               case 3:
+                       break;
+               case 4:
+                       break;
+               case 5:
+                       break;
+               case 6:
+                       break;
+               case 7:
+                       break;
+               case 8:
+                       break;
+               case 9:
+                       break;
+               case 10:
+                       break;
+               case 11:
+                       break;
+               case 12:
+                       break;
+               case 13:
+                       break;
+               case 14:
+                       break;
+               case 15:
+                       break;
+               case 17:
+                       break;
+               /* triggers bug ? */
+               /* gcc warning: case label value exceeds maximum value for type */
+               /* cc65 error: range error */
+
+               /*
+               case 170:
+                       break;
+               */
+               case 18:
+                       break;
+               case 19:
+                       break;
+               case 20:
+                       break;
+               case 21:
+                       break;
+               case 22:
+                       break;
+               case 23:
+                       break;
+               case 24:
+                       switch(k) {
+                               case 1:
+                                       break;
+                               case 2:
+                                       break;
+                               case 3:
+                                       break;
+                               case 4:
+                               case 5:
+                               break;
+                               case 6:
+                               case 7:
+                                       break;
+                               case 8:
+                               case 9:
+                                       break;
+                               }
+                       break;
+               case 100:
+                       break;
+               default:
+                       printf(">>>default\n");
+                       /* triggers bug if this break; is missing? */
+                       /* break; */
+               }
+       }
+}
+
+void testdefault2(unsigned char i) {
+/* we want a unsigned char */
+#ifdef REFCC
+
+#ifdef REFCC_UNSIGNED_CHARS
+char k;
+#else
+unsigned char k;
+#endif
+       
+#else
+       
+#ifdef UNSIGNED_CHARS
+char k;
+#else
+unsigned char k;
+#endif
+
+#endif
+
+       for(;i<254;) {
+               k = i;
+               printf(">%d\n",i);i++;
+               switch(k) {
+               case 1:
+                       break;
+               case 2:
+                       break;
+               case 3:
+                       break;
+               case 4:
+                       break;
+               case 5:
+                       break;
+               case 6:
+                       break;
+               case 7:
+                       break;
+               case 8:
+                       break;
+               case 9:
+                       break;
+               case 10:
+                       break;
+               case 11:
+                       break;
+               case 12:
+                       break;
+               case 13:
+                       break;
+               case 14:
+                       break;
+               case 15:
+                       break;
+               case 17:
+                       break;
+               /* triggers bug ? */
+
+               case 170:
+                       break;
+               
+               case 18:
+                       break;
+               case 19:
+                       break;
+               case 20:
+                       break;
+               case 21:
+                       break;
+               case 22:
+                       break;
+               case 23:
+                       break;
+               case 24:
+                       switch(k) {
+                               case 1:
+                                       break;
+                               case 2:
+                                       break;
+                               case 3:
+                                       break;
+                               case 4:
+                               case 5:
+                               break;
+                               case 6:
+                               case 7:
+                                       break;
+                               case 8:
+                               case 9:
+                                       break;
+                               }
+                       break;
+               case 100:
+                       break;
+               default:
+                       printf(">>>default\n");
+                       /* triggers bug if this break; is missing? */
+                       /* break; */
+               }
+       }
 }
 
 int main(void) {
-       testlimits(32767);\r
-       testlimits(-32768);\r
-       testlimits(-1);\r
-       \r
-       testdefault1(1);\r
-       testdefault1(2);\r
-       testdefault1(3);\r
-       testdefault1(4);\r
-       \r
-       testdefault2(1);\r
-       testdefault2(2);\r
-       testdefault2(3);\r
-       testdefault2(4);\r
-\r
-       return 0;\r
-}\r
+       testlimits(32767);
+       testlimits(-32768);
+       testlimits(-1);
+       
+       testdefault1(1);
+       testdefault1(2);
+       testdefault1(3);
+       testdefault1(4);
+       
+       testdefault2(1);
+       testdefault2(2);
+       testdefault2(3);
+       testdefault2(4);
+
+       return 0;
+}
index 11fd33b3829c615b41da580fa1bf2a5640b1f66d..3d61fdbd0d5b6bcf4fca13696625cdf078066b79 100644 (file)
 /*
-  !!DESCRIPTION!! varargs test\r
-  !!ORIGIN!!\r
-  !!LICENCE!!     public domain\r
-*/\r
-\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-#include <stdarg.h>\r
-\r
-void chk0(char *format,...);\r
-void chk1(int fd,char *format,...);\r
-\r
-#if 0\r
-// old workaround for broken varargs\r
-\r
-void chk0(char *format,...){\r
-    __asm__ ("pha");    // save argument size\r
-    {\r
-//va_list ap;\r
-char *ap;\r
-char *_format;\r
-static char string[0x100];\r
-\r
-//    va_start(ap,format);\r
-    __asm__ ("pla");       // restore argument size\r
-    __asm__ ("ldx #$00");  // clear hibyte of AX\r
-    ap=__AX__;\r
-    ap+=(char*)&format;\r
-    // get value of format\r
-    ap-=2;\r
-    _format=*((char**)ap);\r
-\r
-//    vsprintf(string,format,ap);\r
-    vsprintf(&string[0],_format,ap);\r
-    printf("format:%s,string:%s\n",_format,string);\r
-//    va_end(ap);\r
-\r
-    }\r
-}\r
-\r
-void chk1(int fd,char *format,...){\r
-    __asm__ ("pha");    // save argument size\r
-    {\r
-//va_list ap;\r
-char *ap;\r
-char *_format;\r
-int _fd;\r
-static char string[0x100];\r
-\r
-//    va_start(ap,format);\r
-    __asm__ ("pla");       // restore argument size\r
-    __asm__ ("ldx #$00");  // clear hibyte of AX\r
-    ap=__AX__;\r
-    ap+=(char*)&format;\r
-    // get value of fd\r
-    ap-=2;\r
-    _fd=*((int*)ap);\r
-    // get value of format\r
-    ap-=2;\r
-    _format=*((char**)ap);\r
-\r
-//    vsprintf(string,format,ap);\r
-    vsprintf(&string[0],_format,ap);\r
-    printf("fd:%d,format:%s,string:%s\n",_fd,_format,string);\r
-//    va_end(ap);\r
-\r
-    }\r
-}\r
-\r
-#endif\r
-\r
-void chk0(char *format,...){\r
-va_list ap;\r
-static char string[0x100];\r
-    va_start(ap,format);\r
-    vsprintf(string,format,ap);\r
-    printf("format:%s,string:%s\n",format,string);\r
-    va_end(ap);\r
-}\r
-\r
-void chk1(int fd,char *format,...){\r
-va_list ap;\r
-static char string[0x100];\r
-\r
-    va_start(ap,format);\r
-\r
-    vsprintf(string,format,ap);\r
-       printf("fd:%d,format:%s,string:%s\n",fd,format,string);\r
-    va_end(ap);\r
+  !!DESCRIPTION!! varargs test
+  !!ORIGIN!!
+  !!LICENCE!!     public domain
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+void chk0(char *format,...);
+void chk1(int fd,char *format,...);
+
+#if 0
+// old workaround for broken varargs
+
+void chk0(char *format,...){
+    __asm__ ("pha");    // save argument size
+    {
+//va_list ap;
+char *ap;
+char *_format;
+static char string[0x100];
+
+//    va_start(ap,format);
+    __asm__ ("pla");       // restore argument size
+    __asm__ ("ldx #$00");  // clear hibyte of AX
+    ap=__AX__;
+    ap+=(char*)&format;
+    // get value of format
+    ap-=2;
+    _format=*((char**)ap);
+
+//    vsprintf(string,format,ap);
+    vsprintf(&string[0],_format,ap);
+    printf("format:%s,string:%s\n",_format,string);
+//    va_end(ap);
+
+    }
+}
+
+void chk1(int fd,char *format,...){
+    __asm__ ("pha");    // save argument size
+    {
+//va_list ap;
+char *ap;
+char *_format;
+int _fd;
+static char string[0x100];
+
+//    va_start(ap,format);
+    __asm__ ("pla");       // restore argument size
+    __asm__ ("ldx #$00");  // clear hibyte of AX
+    ap=__AX__;
+    ap+=(char*)&format;
+    // get value of fd
+    ap-=2;
+    _fd=*((int*)ap);
+    // get value of format
+    ap-=2;
+    _format=*((char**)ap);
+
+//    vsprintf(string,format,ap);
+    vsprintf(&string[0],_format,ap);
+    printf("fd:%d,format:%s,string:%s\n",_fd,_format,string);
+//    va_end(ap);
+
+    }
 }
 
-int main(int argc,char **argv) {\r
-    printf("varargs test\n");\r
-\r
-    printf("\nchk0/0:\n");chk0("chk0 %s","arg0");\r
-    printf("\nchk0/1:\n");chk0("chk0 %s %s","arg0","arg1");\r
-    printf("\nchk0/2:\n");chk0("chk0 %s %s %s","arg0","arg1","arg2");\r
-\r
-    printf("\nchk1/0:\n");chk1(0xfd,"chk1 %s","arg0");\r
-    printf("\nchk1/1:\n");chk1(0xfd,"chk1 %s %s","arg0","arg1");\r
-    printf("\nchk1/2:\n");chk1(0xfd,"chk1 %s %s %s","arg0","arg1","arg2");\r
-\r
+#endif
+
+void chk0(char *format,...){
+va_list ap;
+static char string[0x100];
+    va_start(ap,format);
+    vsprintf(string,format,ap);
+    printf("format:%s,string:%s\n",format,string);
+    va_end(ap);
+}
+
+void chk1(int fd,char *format,...){
+va_list ap;
+static char string[0x100];
+
+    va_start(ap,format);
+
+    vsprintf(string,format,ap);
+       printf("fd:%d,format:%s,string:%s\n",fd,format,string);
+    va_end(ap);
+}
+
+int main(int argc,char **argv) {
+    printf("varargs test\n");
+
+    printf("\nchk0/0:\n");chk0("chk0 %s","arg0");
+    printf("\nchk0/1:\n");chk0("chk0 %s %s","arg0","arg1");
+    printf("\nchk0/2:\n");chk0("chk0 %s %s %s","arg0","arg1","arg2");
+
+    printf("\nchk1/0:\n");chk1(0xfd,"chk1 %s","arg0");
+    printf("\nchk1/1:\n");chk1(0xfd,"chk1 %s %s","arg0","arg1");
+    printf("\nchk1/2:\n");chk1(0xfd,"chk1 %s %s %s","arg0","arg1","arg2");
+
     return 0;
-}\r
+}
index 5768f80d00b5fb5708c8db6aa58018ecb0e68882..ab72e24c0881e48868e4d35c6160464b6ae7e3d0 100644 (file)
@@ -562,13 +562,13 @@ yylook()
                }
 
 # ifdef LEXDEBUG
-               if((*(lsp-1)-yysvec-1)<0)
+               if (lsp == yylstate)
                {
                        fprintf(yyout,"yylook:  stopped (end)\n");
                }
                else
                {
-                       fprintf(yyout,"yylook:  stopped at %d with\n",*(lsp-1)-yysvec-1);
+                       fprintf(yyout,"yylook:  stopped at %d with:\n",*(lsp-1)-(yysvec+1));
                }
 # endif
                while (lsp-- > yylstate)
@@ -594,7 +594,7 @@ yylook()
                                yyleng = yylastch-yytext+1;
                                yytext[yyleng] = 0;
 # ifdef LEXDEBUG
-                               fprintf(yyout,"\nyylook:  match action %d\n",*yyfnd);
+                               fprintf(yyout,"yylook:  match action %d\n",*yyfnd);
                                fprintf(yyout,"yylook:  done loops: %d\n",testbreak);
 # endif
                                return(*yyfnd++);
index 4ad8160efbb2080a183229445dd790cc3bb814f8..fe194d892154a94c38e4b57a36262566bfda372c 100644 (file)
@@ -1,70 +1,71 @@
-
-# makefile for the regression tests that return an error code on failure
+# Makefile for the regression tests that return an error code on failure
 
 ifneq ($(shell echo),)
-  CMD_EXE := 1
+  CMD_EXE = 1
 endif
 
 ifdef CMD_EXE
-  DEL = -del /f $(subst /,\,$1)
+  S = $(subst /,\,/)
+  NULLDEV = nul:
+  MKDIR = mkdir $(subst /,\,$1)
+  RMDIR = -rmdir /s /q $(subst /,\,$1)
+  DEL = del /f $(subst /,\,$1)
 else
+  S = /
+  NULLDEV = /dev/null
+  MKDIR = mkdir -p $1
+  RMDIR = $(RM) -r $1
   DEL = $(RM) $1
 endif
 
-CC65FLAGS := -t sim6502
-SIM65FLAGS := -x 200000000
+ifdef QUIET
+  .SILENT:
+  NULLOUT = >$(NULLDEV)
+  NULLERR = 2>$(NULLDEV)
+endif
+
+SIM65FLAGS = -x 200000000
 
-CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
-SIM65 := $(if $(wildcard ../../bin/sim65*),../../bin/sim65,sim65)
+CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65)
+SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)
 
-WORKDIR := ../../testwrk
+WORKDIR = ../../testwrk/val
+
+OPTIONS = g O Os Osi Osir Osr Oi Oir Or
 
 .PHONY: all clean
 
 SOURCES := $(wildcard *.c)
-TESTS := $(foreach option,. .o. .os. .osi. .osir. .oi. .oir. .or.,$(SOURCES:%.c=$(WORKDIR)/%$(option)prg))
+TESTS  = $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).6502.prg))
+TESTS += $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).65c02.prg))
 
 all: $(TESTS)
 
+$(WORKDIR):
+       $(call MKDIR,$(WORKDIR))
+
 # Some files have "K & R"-style syntax.  Therefore, some forward
 # function-declarations don't match the later function definitions.
 # Those programs fail when fastcall is used; but, the cdecl calling convention
 # tolerates those conflicts.  Therefore, make their functions default to cdecl.
 #
-$(WORKDIR)/cq4%prg $(WORKDIR)/cq71.%rg $(WORKDIR)/cq81%prg $(WORKDIR)/cq84%prg: CC65FLAGS += -Wc --all-cdecl
-
-$(WORKDIR)/%.prg: %.c
-       $(CL65) $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@
-
-$(WORKDIR)/%.o.prg: %.c
-       $(CL65) -O $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@
-
-$(WORKDIR)/%.os.prg: %.c
-       $(CL65) -Os $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@
-
-$(WORKDIR)/%.osi.prg: %.c
-       $(CL65) -Osi $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@
+$(WORKDIR)/cq4.%.prg  \
+$(WORKDIR)/cq71.%.prg \
+$(WORKDIR)/cq81.%.prg \
+$(WORKDIR)/cq84.%.prg: CC65FLAGS += -Wc --all-cdecl
 
-$(WORKDIR)/%.osir.prg: %.c
-       $(CL65) -Osir $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@
+define PRG_template
 
-$(WORKDIR)/%.oi.prg: %.c
-       $(CL65) -Oi $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@
+$(WORKDIR)/%.$1.$2.prg: %.c | $(WORKDIR)
+       $(if $(QUIET),echo val/$$*.$1.$2.prg)
+       $(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< $(NULLERR)
+       $(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT)
 
-$(WORKDIR)/%.oir.prg: %.c
-       $(CL65) -Oir $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@
+endef # PRG_template
 
-$(WORKDIR)/%.or.prg: %.c
-       $(CL65) -Or $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@
+$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),6502)))
+$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02)))
 
 clean:
-       @$(call DEL,$(TESTS))
+       @$(call RMDIR,$(WORKDIR))
        @$(call DEL,$(SOURCES:.c=.o))
diff --git a/test/val/atoi-test.c b/test/val/atoi-test.c
deleted file mode 100644 (file)
index 5f5fa65..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
-  !!DESCRIPTION!! A small test for atoi. Assumes twos complement
-  !!ORIGIN!!
-  !!LICENCE!!
-  !!AUTHOR!!
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include <errno.h>
-
-static unsigned int Failures = 0;
-
-static void CheckAtoi (const char* Str, int Val)
-{
-    int Res = atoi (Str);
-    if (Res != Val) {
-        printf ("atoi error in \"%s\":\n"
-                "  result = %d, should be %d\n", Str, Res, Val);
-        ++Failures;
-    }
-}
-
-int main (void)
-{
-    CheckAtoi ("\t +0A", 0);
-    CheckAtoi ("\t -0.123", 0);
-    CheckAtoi ("  -32  ", -32);
-    CheckAtoi (" +32  ", 32);
-    CheckAtoi ("0377", 377);
-    CheckAtoi (" 0377 ", 377);
-    CheckAtoi (" +0377 ", 377);
-    CheckAtoi (" -0377 ", -377);
-    CheckAtoi ("0x7FFF", 0);
-    CheckAtoi (" +0x7FFF", 0);
-    CheckAtoi (" -0x7FFF", 0);
-    printf ("Failures: %u\n", Failures);
-
-    return Failures;
-}
diff --git a/test/val/bss-name-decl.c b/test/val/bss-name-decl.c
new file mode 100644 (file)
index 0000000..9a53584
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+  !!DESCRIPTION!! bss-name pragma not affecting declarations
+  !!ORIGIN!!      cc65 regression tests
+  !!LICENCE!!     Public Domain
+  !!AUTHOR!!      Piotr Fusik
+*/
+
+/*
+  see: https://github.com/cc65/cc65/issues/409
+*/
+
+#pragma bss-name (push,"ZEROPAGE")
+
+char n; /* only a declaration because followed by definition */
+char n = 1; /* not BSS */
+
+#pragma bss-name (pop)
+
+int main(void)
+{
+    return (unsigned) &n >= 0x100 ? 0 : 1;
+}
diff --git a/test/val/bss-name.c b/test/val/bss-name.c
new file mode 100644 (file)
index 0000000..f0ad711
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+  !!DESCRIPTION!! bss-name pragma
+  !!ORIGIN!!      cc65 regression tests
+  !!LICENCE!!     Public Domain
+  !!AUTHOR!!      Piotr Fusik
+*/
+
+/*
+  see: https://github.com/cc65/cc65/issues/409
+*/
+
+#pragma bss-name (push,"ZEROPAGE")
+
+char zp_var;
+
+#pragma bss-name (pop)
+
+int main(void)
+{
+    return (unsigned) &zp_var < 0x100 ? 0 : 1;
+}
diff --git a/test/val/lib_common_atoi.c b/test/val/lib_common_atoi.c
new file mode 100644 (file)
index 0000000..5f5fa65
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+  !!DESCRIPTION!! A small test for atoi. Assumes twos complement
+  !!ORIGIN!!
+  !!LICENCE!!
+  !!AUTHOR!!
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <errno.h>
+
+static unsigned int Failures = 0;
+
+static void CheckAtoi (const char* Str, int Val)
+{
+    int Res = atoi (Str);
+    if (Res != Val) {
+        printf ("atoi error in \"%s\":\n"
+                "  result = %d, should be %d\n", Str, Res, Val);
+        ++Failures;
+    }
+}
+
+int main (void)
+{
+    CheckAtoi ("\t +0A", 0);
+    CheckAtoi ("\t -0.123", 0);
+    CheckAtoi ("  -32  ", -32);
+    CheckAtoi (" +32  ", 32);
+    CheckAtoi ("0377", 377);
+    CheckAtoi (" 0377 ", 377);
+    CheckAtoi (" +0377 ", 377);
+    CheckAtoi (" -0377 ", -377);
+    CheckAtoi ("0x7FFF", 0);
+    CheckAtoi (" +0x7FFF", 0);
+    CheckAtoi (" -0x7FFF", 0);
+    printf ("Failures: %u\n", Failures);
+
+    return Failures;
+}
diff --git a/test/val/lib_common_memmove.c b/test/val/lib_common_memmove.c
new file mode 100644 (file)
index 0000000..6b2273e
--- /dev/null
@@ -0,0 +1,58 @@
+#include <string.h>
+#include "unittest.h"
+
+#define BufferSize 384               // test correct page passing (>256, multiple of 128 here)
+
+static char Buffer[BufferSize+3];    // +1 to move up (and down)
+
+
+TEST
+{
+    unsigned i, v;
+    char*    p;
+    
+    for (i=0; i < BufferSize; ++i)
+      Buffer[i+1] = (i%128);
+
+    Buffer[0] = 255;                  // to check if start position is untouched
+    Buffer[BufferSize+2] = 255;       // to check if end position is untouched
+
+    // copy upwards
+    p = memmove(Buffer+2, Buffer+1, BufferSize);
+
+    // check buffer consistency before target
+    ASSERT_AreEqual(255, (unsigned)Buffer[0], "%u", "Unexpected value before range!");
+
+    // check buffer consistency at starting point
+    ASSERT_AreEqual(0, (unsigned)Buffer[1], "%u", "Unexpected value at range start!");
+
+    // check buffer consistency after range
+    ASSERT_AreEqual(255, (unsigned)Buffer[BufferSize+2], "%u", "Unexpected value after range!");
+
+    // check buffer values
+    for (i=0; i < BufferSize; ++i)
+    {
+        ASSERT_AreEqual(i%128, (unsigned)Buffer[i+2], "%u", "Unexpected value in buffer at position %u!" COMMA i+2);
+    }
+
+    v = Buffer[BufferSize+1];   // rember value of first untouched end-byte 
+
+    // copy downwards
+    p = memmove(Buffer+1, Buffer+2, BufferSize);
+
+    // check buffer consistency before target
+    ASSERT_AreEqual(255, (unsigned)Buffer[0], "%u", "Unexpected value before range!");
+
+    // check buffer consistency at end point
+    ASSERT_AreEqual(v, (unsigned)Buffer[BufferSize+1], "%u", "Unexpected value at range end!");
+
+    // check buffer consistency after range
+    ASSERT_AreEqual(255, (unsigned)Buffer[BufferSize+2], "%u", "Unexpected value after range!");
+
+    // check buffer values
+    for (i=0; i < BufferSize; ++i)
+    {
+        ASSERT_AreEqual(i%128, (unsigned)Buffer[i+1], "%u", "Unexpected value in buffer at position %u!" COMMA i+1);
+    }
+}
+ENDTEST
diff --git a/test/val/lib_common_strcat.c b/test/val/lib_common_strcat.c
new file mode 100644 (file)
index 0000000..1872053
--- /dev/null
@@ -0,0 +1,54 @@
+#include <string.h>
+#include "unittest.h"
+
+#define SourceStringSize 257                            // test correct page passing (>256)
+
+static char SourceString[SourceStringSize+1];           // +1 room for terminating null
+static char DestinationString[2*SourceStringSize+1];    // will contain two times the source buffer
+
+
+TEST
+{
+    unsigned i,j;
+    char*    p;
+    
+    for (i=0; i < SourceStringSize; ++i)
+      SourceString[i] = (i%128)+1;
+
+    SourceString[i] = 0;
+
+    ASSERT_AreEqual(SourceStringSize, strlen(SourceString), "%u", "Source string initialization or 'strlen()' problem!");
+
+    /* Ensure empty destination string */
+    DestinationString[0] = 0;
+
+    ASSERT_AreEqual(0, strlen(DestinationString), "%u", "Destination string initialization or 'strlen()' problem!");
+    
+    /* Test concatenation to empty buffer */
+
+    strcat(DestinationString, SourceString);
+    
+    ASSERT_AreEqual(SourceStringSize, strlen(DestinationString), "%u", "Unexpected string length while string concatenation to empty buffer!");
+    
+    /* Test concatenation to non empty buffer */
+
+    p = strcat(DestinationString, SourceString);
+
+    ASSERT_AreEqual(2*SourceStringSize, strlen(DestinationString), "%u", "Unexpected string length while string concatenation to non-empty buffer!");
+
+    /* Test return value */
+
+    ASSERT_IsTrue(p == DestinationString,"Invalid return value!");
+
+    /* Test contents */
+
+    for(j=0; j <2; ++j)
+        for(i=0; i < SourceStringSize; ++i)
+        {
+            unsigned position = j*SourceStringSize+i;
+            unsigned current = DestinationString[position];
+            unsigned expected = (i%128)+1;
+            ASSERT_AreEqual(expected, current, "%u", "Unexpected destination buffer contents at position %u!\n" COMMA position);
+        }
+}
+ENDTEST
diff --git a/test/val/lib_common_strchr.c b/test/val/lib_common_strchr.c
new file mode 100644 (file)
index 0000000..a48d287
--- /dev/null
@@ -0,0 +1,42 @@
+#include <string.h>
+#include "unittest.h"
+
+                                                        
+/* Test string. Must NOT have duplicate characters! */
+static char S[] = "Helo wrd!\n";
+
+static char Found[256];
+
+
+
+TEST
+{
+    unsigned Len;
+    unsigned I;
+    char*    P;
+
+    /* Get the length of the string */
+    Len = strlen (S);
+
+    /* Search for all characters in the string, including the terminator */
+    for (I = 0; I < Len+1; ++I)
+    {
+        /* Search for this char */
+        P = strchr (S, S[I]);
+
+        /* Check if we found it */
+        ASSERT_IsFalse(P == 0 || (P - S) != I, "For code 0x%02X, offset %u!\nP = %04X offset = %04X\n" COMMA S[I] COMMA I COMMA P COMMA P-S);
+        /* Mark the char as checked */
+        Found[S[I]] = 1;
+    }
+
+    /* Search for all other characters and make sure they aren't found */
+    for (I = 0; I < 256; ++I)
+    {
+        if (Found[I] == 0)
+        {
+            ASSERT_IsFalse(strchr (S, (char)I), "Failed for code 0x%02X\n" COMMA I);
+        }
+    }
+}
+ENDTEST
diff --git a/test/val/lib_common_strcspn.c b/test/val/lib_common_strcspn.c
new file mode 100644 (file)
index 0000000..f289ddb
--- /dev/null
@@ -0,0 +1,25 @@
+#include <string.h>
+#include "unittest.h"
+
+#define EstimatedStringSize 384                         // test correct page passing (>256)
+
+static char EstimatedString[EstimatedStringSize+1];     // +1 room for terminating null
+static char* EmptyTestChars="";                         // strlen equivalent...
+static char* TestChars="1234567890";                    // we like to find numbers
+
+
+TEST
+{
+    unsigned i;
+    
+    for (i=0; i < EstimatedStringSize; ++i)
+      EstimatedString[i] = (i%26)+'A';                 // put ABCD... into the string to be estimated
+
+    ASSERT_AreEqual(strlen(EstimatedString), strcspn(EstimatedString, TestChars), "%u", "Unxpected position returned for non-participant case!");
+
+    EstimatedString[EstimatedStringSize/2] = TestChars[strlen(TestChars-1)];
+    ASSERT_AreEqual(EstimatedStringSize/2, strcspn(EstimatedString, TestChars), "%u", "Unxpected position returned for participant case!");
+
+    ASSERT_AreEqual(strlen(EstimatedString), strcspn(EstimatedString, EmptyTestChars), "%u", "Unxpected position returned for empty test case!");
+}
+ENDTEST
diff --git a/test/val/lib_common_strncat.c b/test/val/lib_common_strncat.c
new file mode 100644 (file)
index 0000000..a6f92ac
--- /dev/null
@@ -0,0 +1,52 @@
+#include <string.h>
+#include "unittest.h"
+
+#define SourceStringSize 384                            // test correct page passing (>256, multiple of 128 here)
+
+static char SourceString[SourceStringSize+1];           // +1 room for terminating null
+static char DestinationString[2*SourceStringSize+1];    // will contain two times the source buffer
+
+
+TEST
+{
+    unsigned i;
+    char*    p;
+    
+    for (i=0; i < SourceStringSize; ++i)
+      SourceString[i] = (i%128)+1;
+
+    SourceString[i] = 0;
+
+    ASSERT_AreEqual(SourceStringSize, strlen(SourceString), "%u", "Source string initialization or 'strlen()' problem!");
+
+    /* Ensure empty destination string */
+    DestinationString[0] = 0;
+
+    ASSERT_AreEqual(0, strlen(DestinationString), "%u", "Destination string initialization or 'strlen()' problem!");
+    
+    /* Test "unlimted" concatenation to empty buffer */
+
+    strncat(DestinationString, SourceString, 1024);
+    
+    ASSERT_AreEqual(SourceStringSize, strlen(DestinationString), "%u", "Unexpected string length while string concatenation to empty buffer!");
+    
+    /* Test limited concatenation to non empty buffer */
+
+    p = strncat(DestinationString, SourceString, 128);
+
+    ASSERT_AreEqual(SourceStringSize+128, strlen(DestinationString), "%u", "Unexpected string length while string concatenation to non-empty buffer!");
+
+    /* Test return value */
+
+    ASSERT_IsTrue(p == DestinationString, "Invalid return value!");
+
+    /* Test contents */
+
+    for(i=0; i < strlen(DestinationString); ++i)
+    {
+        unsigned current = DestinationString[i];
+        unsigned expected = (i%128)+1;
+        ASSERT_AreEqual(expected, current, "%u", "Unexpected destination buffer contents at position %u!\n" COMMA i);
+    }
+}
+ENDTEST
diff --git a/test/val/lib_common_strol.c b/test/val/lib_common_strol.c
new file mode 100644 (file)
index 0000000..76daef7
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+  !!DESCRIPTION!! A small test for atoi/strtol. Assumes twos complement
+  !!ORIGIN!!
+  !!LICENCE!!
+  !!AUTHOR!!
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <errno.h>
+
+#define ERROR   0
+#define OK      1
+
+static unsigned int Failures = 0;
+
+static void IncStr (char* Buf)
+/* Increment a number represented as a string by one. The string MUST not
+ * start with a '9', we cannot handle overflow in this case.
+ */
+{
+    int Len = strlen (Buf);
+
+    while (--Len >= 0) {
+        switch (Buf[Len]) {
+            case '9':
+                Buf[Len] = '0';
+                break;
+
+            default:
+                ++(Buf[Len]);
+                return;
+        }
+    }
+}
+
+static void CheckStrToL (const char* Str, int Base, long Val, unsigned char Ok)
+{
+    char* EndPtr;
+    long Res = strtol (Str, &EndPtr, Base);
+    if (Ok) {
+        if (Res != Val) {
+            printf ("strtol error in \"%s\":\n"
+                    "  result = %ld, should be %ld, chars = %d\n",
+                    Str, Res, Val, EndPtr - Str);
+            ++Failures;
+        }
+    } else {
+        if (errno != ERANGE) {
+            printf ("strtol error in \"%s\":\n"
+                    "  should not convert, but errno = %d\n",
+                    Str, errno);
+            ++Failures;
+        }
+        if (Res != Val) {
+            printf ("strtol error in \"%s\":\n"
+                    "  result = %ld, should be %ld, chars = %d\n",
+                    Str, Res, Val, EndPtr - Str);
+            ++Failures;
+        }
+    }
+}
+
+int main (void)
+{
+    char Buf[80];
+
+    /* Prefixed allowed if base = 0 */
+    CheckStrToL ("\t 0x10G ", 0, 16L, OK);
+    CheckStrToL ("\t 0X10G ", 0, 16L, OK);
+    CheckStrToL (" \t0377\t", 0, 255L, OK);
+    CheckStrToL (" 377", 0, 377L, OK);
+
+    CheckStrToL ("\t -0x10G ", 0, -16L, OK);
+    CheckStrToL ("\t -0X10G ", 0, -16L, OK);
+    CheckStrToL (" \t-0377\t", 0, -255L, OK);
+    CheckStrToL (" -377", 0, -377L, OK);
+
+    /* No prefixes if base = 10 */
+    CheckStrToL ("\t 1234 ", 10, 1234L, OK);
+    CheckStrToL ("\t -1234 ", 10, -1234L, OK);
+    CheckStrToL ("\t -0x10G ", 10, 0L, OK);
+    CheckStrToL ("\t -0X10G ", 10, 0L, OK);
+    CheckStrToL (" \t-0377\t", 10, -377L, OK);
+    CheckStrToL (" 0377", 10, 377L, OK);
+
+    /* 0x prefix is allowed if base = 16 */
+    CheckStrToL ("\t 0x1234 ", 16, 0x1234L, OK);
+    CheckStrToL ("\t -0x1234 ", 16, -0x1234L, OK);
+    CheckStrToL ("\t -010G ", 16, -16L, OK);
+    CheckStrToL ("\t 10G ", 16, 16L, OK);
+
+    /* Check LONG_MIN and LONG_MAX */
+    sprintf (Buf, "%ld", LONG_MIN);
+    CheckStrToL (Buf, 0, LONG_MIN, OK);
+    sprintf (Buf, "%ld", LONG_MAX);
+    CheckStrToL (Buf, 0, LONG_MAX, OK);
+
+    /* Check value one smaller */
+    sprintf (Buf+1, "%ld", LONG_MIN);
+    Buf[1] = '0';       /* Overwrite '-' */
+    IncStr (Buf+1);
+    if (Buf[1] == '0') {
+        Buf[1] = '-';
+        Buf[0] = ' ';
+    } else {
+        Buf[0] = '-';
+    }
+    CheckStrToL (Buf, 0, LONG_MIN, ERROR);
+
+    /* Check value one larger */
+    sprintf (Buf+1, "%ld", LONG_MAX);
+    Buf[0] = '0';
+    IncStr (Buf);
+    if (Buf[0] == '0') {
+        Buf[0] = ' ';
+    }
+    CheckStrToL (Buf, 0, LONG_MAX, ERROR);
+
+    /* Check numbers that are much too large or small */
+    CheckStrToL ("-999999999999999999999999999999999999999999999999999999999", 0, LONG_MIN, ERROR);
+    CheckStrToL ("+999999999999999999999999999999999999999999999999999999999", 0, LONG_MAX, ERROR);
+    CheckStrToL (" 999999999999999999999999999999999999999999999999999999999", 0, LONG_MAX, ERROR);
+
+    /* Check a few other bases */
+    CheckStrToL ("aBcD", 36, 481261L, OK);
+    CheckStrToL ("zyaB", 35, 0L, ERROR);
+    CheckStrToL ("zyaB", 36, 1677395L, ERROR);
+
+    printf ("Failures: %u\n", Failures);
+
+    return Failures;
+}
diff --git a/test/val/lib_common_strrchr.c b/test/val/lib_common_strrchr.c
new file mode 100644 (file)
index 0000000..a72c44d
--- /dev/null
@@ -0,0 +1,38 @@
+#include <string.h>
+#include "unittest.h"
+                                                    
+static char TestString[] = "01234567890123456789";  // two times the same string
+static char Found[256];
+
+TEST
+{
+    unsigned len;
+    unsigned i;
+    char*    p;
+
+    len = strlen(TestString)/2; // test only one half of the string, to find last appearance
+
+    /* Search for all characters in the string, including the terminator */
+    for (i = 0; i < len; ++i)
+    {
+        /* Search for this char */
+        p = strrchr (TestString, TestString[i]);
+        ASSERT_AreEqual(i+len, p-TestString, "%u", "Unexpected location of character '%c' found!" COMMA TestString[i]);
+
+        /* Mark the char as checked */
+        Found[TestString[i]] = 1;
+    }
+
+    /* Search for all other characters and make sure they aren't found */
+    for (i = 0; i < 256; ++i)
+    {
+        if (!Found[i])
+        {
+            p = strrchr (TestString, i);
+            ASSERT_IsFalse(p, "Unexpected location of character '%c' found!" COMMA TestString[i]);
+        }
+    }
+}
+ENDTEST
+
+
diff --git a/test/val/lib_common_strspn.c b/test/val/lib_common_strspn.c
new file mode 100644 (file)
index 0000000..96a0064
--- /dev/null
@@ -0,0 +1,24 @@
+#include <string.h>
+#include "unittest.h"
+
+#define EstimatedStringSize 384                         // test correct page passing (>256)
+
+static char EstimatedString[EstimatedStringSize+1];     // +1 room for terminating null
+static char* EmptyTestChars="";                         // empty test case...
+static char* TestChars="1234567890";                    // we like to find numbers
+
+TEST
+{
+    unsigned i;
+    
+    for (i=0; i < EstimatedStringSize; ++i)
+      EstimatedString[i] = (i%10)+'0';                 // put 0123... into the string to be estimated
+
+    ASSERT_AreEqual(strlen(EstimatedString), strspn(EstimatedString, TestChars), "%u", "Unxpected position returned for all participant case!");
+
+    EstimatedString[EstimatedStringSize/2] = 'X';
+    ASSERT_AreEqual(EstimatedStringSize/2, strspn(EstimatedString, TestChars), "%u", "Unxpected position returned for breaking case!");
+
+    ASSERT_AreEqual(0, strspn(EstimatedString, EmptyTestChars), "%u", "Unxpected position returned for empty test case!");
+}
+ENDTEST
diff --git a/test/val/lib_common_strtoul.c b/test/val/lib_common_strtoul.c
new file mode 100644 (file)
index 0000000..803fd45
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+  !!DESCRIPTION!! A small test for strtuol. Assumes twos complement
+  !!ORIGIN!!
+  !!LICENCE!!
+  !!AUTHOR!!
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <errno.h>
+
+#define ERROR   0
+#define OK      1
+
+static unsigned int Failures = 0;
+
+static void IncStr (char* Buf)
+/* Increment a number represented as a string by one. The string MUST not
+ * start with a '9', we cannot handle overflow in this case.
+ */
+{
+    int Len = strlen (Buf);
+
+    while (--Len >= 0) {
+        switch (Buf[Len]) {
+            case '9':
+                Buf[Len] = '0';
+                break;
+
+            default:
+                ++(Buf[Len]);
+                return;
+        }
+    }
+}
+
+static void CheckStrToUL (const char* Str, int Base, unsigned long Val, unsigned char Ok)
+{
+    char* EndPtr;
+    unsigned long Res = strtoul (Str, &EndPtr, Base);
+    if (Ok) {
+        if (Res != Val) {
+            printf ("strtol error in \"%s\":\n"
+                    "  result = %lu, should be %lu, chars = %d\n",
+                    Str, Res, Val, EndPtr - Str);
+            ++Failures;
+        }
+    } else {
+        if (errno != ERANGE) {
+            printf ("strtol error in \"%s\":\n"
+                    "  should not convert, but errno = %d\n",
+                    Str, errno);
+            ++Failures;
+        }
+        if (Res != Val) {
+            printf ("strtol error in \"%s\":\n"
+                    "  result = %lu, should be %lu, chars = %d\n",
+                    Str, Res, Val, EndPtr - Str);
+            ++Failures;
+        }
+    }
+}
+
+int main (void)
+{
+    char Buf[80];
+
+    /* Prefixed allowed if base = 0 */
+    CheckStrToUL ("\t 0x10G ", 0, 16UL, OK);
+    CheckStrToUL ("\t 0X10G ", 0, 16UL, OK);
+    CheckStrToUL (" \t0377\t", 0, 255UL, OK);
+    CheckStrToUL (" 377", 0, 377UL, OK);
+
+    CheckStrToUL ("\t -0x10G ", 0, (unsigned long) -16L, OK);
+    CheckStrToUL ("\t -0X10G ", 0, (unsigned long) -16L, OK);
+    CheckStrToUL (" \t-0377\t", 0, (unsigned long) -255L, OK);
+    CheckStrToUL (" -377", 0, (unsigned long) -377L, OK);
+
+    /* No prefixes if base = 10 */
+    CheckStrToUL ("\t 1234 ", 10, 1234UL, OK);
+    CheckStrToUL ("\t -1234 ", 10, (unsigned long) -1234L, OK);
+    CheckStrToUL ("\t -0x10G ", 10, 0UL, OK);
+    CheckStrToUL ("\t -0X10G ", 10, 0UL, OK);
+    CheckStrToUL (" \t-0377\t", 10, (unsigned long) -377L, OK);
+    CheckStrToUL (" 0377", 10, 377UL, OK);
+
+    /* 0x prefix is allowed if base = 16 */
+    CheckStrToUL ("\t 0x1234 ", 16, 0x1234UL, OK);
+    CheckStrToUL ("\t -0x1234 ", 16, (unsigned long) -0x1234L, OK);
+    CheckStrToUL ("\t -010G ", 16, (unsigned long) -16L, OK);
+    CheckStrToUL ("\t 10G ", 16, 16UL, OK);
+
+    /* Check ULONG_MAX */
+    sprintf (Buf, "%lu", ULONG_MAX);
+    CheckStrToUL (Buf, 0, ULONG_MAX, OK);
+
+    /* Check value one larger */
+    sprintf (Buf+1, "%lu", ULONG_MAX);
+    Buf[0] = '0';
+    IncStr (Buf);
+    if (Buf[0] == '0') {
+        Buf[0] = ' ';
+    }
+    CheckStrToUL (Buf, 0, ULONG_MAX, ERROR);
+
+    /* Check numbers that are much too large or small */
+    CheckStrToUL ("-999999999999999999999999999999999999999999999999999999999", 0, ULONG_MAX, ERROR);
+    CheckStrToUL ("+999999999999999999999999999999999999999999999999999999999", 0, ULONG_MAX, ERROR);
+    CheckStrToUL (" 999999999999999999999999999999999999999999999999999999999", 0, ULONG_MAX, ERROR);
+
+    /* Check a few other bases */
+    CheckStrToUL ("aBcD", 36, 481261UL, OK);
+    CheckStrToUL ("zyaB", 35, 0UL, ERROR);
+    CheckStrToUL ("zyaB", 36, 1677395UL, ERROR);
+
+    printf ("Failures: %u\n", Failures);
+
+    return Failures;
+}
diff --git a/test/val/lz4.c b/test/val/lz4.c
new file mode 100644 (file)
index 0000000..dceefbf
--- /dev/null
@@ -0,0 +1,669 @@
+/*
+  !!DESCRIPTION!! lz4 decompression
+  !!ORIGIN!!      cc65 regression tests
+  !!LICENCE!!     BSD 2-clause
+  !!AUTHOR!!      Lauri Kasanen
+*/
+
+#include <zlib.h>
+#include <stdio.h>
+#include <lz4.h>
+
+/* The sample data is the original lz4.h, compressed with lz4 hc */
+static const unsigned char compressed[] = {
+0xf0, 0x1a, 0x2f, 0x2a, 0x0a, 0x20, 0x20, 0x20, 0x4c, 0x5a, 0x34, 0x20,
+0x2d, 0x20, 0x46, 0x61, 0x73, 0x74, 0x20, 0x4c, 0x5a, 0x20, 0x63, 0x6f,
+0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x61, 0x6c,
+0x67, 0x6f, 0x72, 0x69, 0x74, 0x68, 0x6d, 0x27, 0x00, 0xb0, 0x48, 0x65,
+0x61, 0x64, 0x65, 0x72, 0x20, 0x46, 0x69, 0x6c, 0x65, 0x0f, 0x00, 0xf0,
+0x17, 0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x20, 0x28,
+0x43, 0x29, 0x20, 0x32, 0x30, 0x31, 0x31, 0x2d, 0x32, 0x30, 0x31, 0x35,
+0x2c, 0x20, 0x59, 0x61, 0x6e, 0x6e, 0x20, 0x43, 0x6f, 0x6c, 0x6c, 0x65,
+0x74, 0x2e, 0x0a, 0x2a, 0x00, 0xf2, 0x22, 0x42, 0x53, 0x44, 0x20, 0x32,
+0x2d, 0x43, 0x6c, 0x61, 0x75, 0x73, 0x65, 0x20, 0x4c, 0x69, 0x63, 0x65,
+0x6e, 0x73, 0x65, 0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f,
+0x77, 0x77, 0x77, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x73, 0x6f, 0x75, 0x72,
+0x63, 0x65, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x6c, 0x23, 0x00, 0x63, 0x73,
+0x2f, 0x62, 0x73, 0x64, 0x2d, 0x0d, 0x00, 0x51, 0x2e, 0x70, 0x68, 0x70,
+0x29, 0x4e, 0x00, 0xb1, 0x52, 0x65, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69,
+0x62, 0x75, 0x74, 0xa3, 0x00, 0x30, 0x6e, 0x64, 0x20, 0x58, 0x00, 0x32,
+0x69, 0x6e, 0x20, 0x43, 0x00, 0x01, 0x12, 0x00, 0xf1, 0x06, 0x62, 0x69,
+0x6e, 0x61, 0x72, 0x79, 0x20, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x2c, 0x20,
+0x77, 0x69, 0x74, 0x68, 0x20, 0x6f, 0x72, 0x08, 0x00, 0x30, 0x6f, 0x75,
+0x74, 0x46, 0x00, 0x80, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x63, 0x61,
+0x44, 0x00, 0xf0, 0x22, 0x2c, 0x20, 0x61, 0x72, 0x65, 0x20, 0x70, 0x65,
+0x72, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x64, 0x20, 0x70, 0x72, 0x6f, 0x76,
+0x69, 0x64, 0x65, 0x64, 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 0x74, 0x68,
+0x65, 0x20, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x69, 0x6e, 0x67, 0x20,
+0x63, 0x6f, 0x6e, 0x64, 0x69, 0x35, 0x00, 0x10, 0x73, 0x35, 0x00, 0x01,
+0x4a, 0x00, 0x31, 0x65, 0x74, 0x3a, 0x99, 0x00, 0x00, 0x01, 0x00, 0x1b,
+0x2a, 0x9f, 0x00, 0x44, 0x73, 0x20, 0x6f, 0x66, 0x98, 0x00, 0xf1, 0x01,
+0x63, 0x6f, 0x64, 0x65, 0x20, 0x6d, 0x75, 0x73, 0x74, 0x20, 0x72, 0x65,
+0x74, 0x61, 0x69, 0x6e, 0x5a, 0x00, 0x40, 0x61, 0x62, 0x6f, 0x76, 0x1b,
+0x00, 0x03, 0x4c, 0x01, 0x00, 0x48, 0x00, 0xf0, 0x02, 0x6e, 0x6f, 0x74,
+0x69, 0x63, 0x65, 0x2c, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x6c, 0x69,
+0x73, 0x74, 0x44, 0x00, 0x08, 0x78, 0x00, 0x2b, 0x6e, 0x64, 0x95, 0x00,
+0xbf, 0x64, 0x69, 0x73, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x65, 0x72, 0x2e,
+0x89, 0x00, 0x07, 0x28, 0x69, 0x6e, 0x16, 0x01, 0x04, 0x89, 0x00, 0x76,
+0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x8c, 0x00, 0x00, 0x41, 0x00,
+0x05, 0x8f, 0x00, 0x0f, 0x8c, 0x00, 0x2a, 0x00, 0x4a, 0x00, 0x03, 0xe6,
+0x00, 0x94, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0xb3,
+0x01, 0xf6, 0x04, 0x2f, 0x6f, 0x72, 0x20, 0x6f, 0x74, 0x68, 0x65, 0x72,
+0x20, 0x6d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x73, 0x77, 0x01,
+0x01, 0xaf, 0x01, 0x21, 0x74, 0x68, 0x8b, 0x00, 0x08, 0xc4, 0x00, 0x02,
+0x4e, 0x02, 0xf0, 0x34, 0x54, 0x48, 0x49, 0x53, 0x20, 0x53, 0x4f, 0x46,
+0x54, 0x57, 0x41, 0x52, 0x45, 0x20, 0x49, 0x53, 0x20, 0x50, 0x52, 0x4f,
+0x56, 0x49, 0x44, 0x45, 0x44, 0x20, 0x42, 0x59, 0x20, 0x54, 0x48, 0x45,
+0x20, 0x43, 0x4f, 0x50, 0x59, 0x52, 0x49, 0x47, 0x48, 0x54, 0x20, 0x48,
+0x4f, 0x4c, 0x44, 0x45, 0x52, 0x53, 0x20, 0x41, 0x4e, 0x44, 0x20, 0x43,
+0x4f, 0x4e, 0x54, 0x52, 0x49, 0x42, 0x55, 0x54, 0x4f, 0x52, 0x53, 0x47,
+0x00, 0x71, 0x22, 0x41, 0x53, 0x20, 0x49, 0x53, 0x22, 0x1c, 0x00, 0xf1,
+0x26, 0x41, 0x4e, 0x59, 0x20, 0x45, 0x58, 0x50, 0x52, 0x45, 0x53, 0x53,
+0x20, 0x4f, 0x52, 0x20, 0x49, 0x4d, 0x50, 0x4c, 0x49, 0x45, 0x44, 0x20,
+0x57, 0x41, 0x52, 0x52, 0x41, 0x4e, 0x54, 0x49, 0x45, 0x53, 0x2c, 0x20,
+0x49, 0x4e, 0x43, 0x4c, 0x55, 0x44, 0x49, 0x4e, 0x47, 0x2c, 0x20, 0x42,
+0x55, 0x54, 0x20, 0x4e, 0x4f, 0x54, 0x3a, 0x03, 0xa1, 0x49, 0x4d, 0x49,
+0x54, 0x45, 0x44, 0x20, 0x54, 0x4f, 0x2c, 0x7b, 0x00, 0x0e, 0x3a, 0x00,
+0xf1, 0x04, 0x20, 0x4f, 0x46, 0x20, 0x4d, 0x45, 0x52, 0x43, 0x48, 0x41,
+0x4e, 0x54, 0x41, 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x73, 0x00, 0x40,
+0x46, 0x49, 0x54, 0x4e, 0x6f, 0x00, 0x30, 0x46, 0x4f, 0x52, 0x49, 0x00,
+0xf0, 0x06, 0x41, 0x20, 0x50, 0x41, 0x52, 0x54, 0x49, 0x43, 0x55, 0x4c,
+0x41, 0x52, 0x20, 0x50, 0x55, 0x52, 0x50, 0x4f, 0x53, 0x45, 0x20, 0xe0,
+0x00, 0xfa, 0x0e, 0x44, 0x49, 0x53, 0x43, 0x4c, 0x41, 0x49, 0x4d, 0x45,
+0x44, 0x2e, 0x20, 0x49, 0x4e, 0x20, 0x4e, 0x4f, 0x20, 0x45, 0x56, 0x45,
+0x4e, 0x54, 0x20, 0x53, 0x48, 0x41, 0x4c, 0x4c, 0xef, 0x00, 0x00, 0x48,
+0x00, 0x50, 0x4f, 0x57, 0x4e, 0x45, 0x52, 0xc4, 0x00, 0x08, 0xef, 0x00,
+0xa0, 0x20, 0x42, 0x45, 0x20, 0x4c, 0x49, 0x41, 0x42, 0x4c, 0x45, 0x6f,
+0x00, 0x01, 0xee, 0x00, 0x60, 0x44, 0x49, 0x52, 0x45, 0x43, 0x54, 0xd7,
+0x00, 0x06, 0x0a, 0x00, 0x90, 0x43, 0x49, 0x44, 0x45, 0x4e, 0x54, 0x41,
+0x4c, 0x2c, 0x49, 0x00, 0xf3, 0x04, 0x53, 0x50, 0x45, 0x43, 0x49, 0x41,
+0x4c, 0x2c, 0x20, 0x45, 0x58, 0x45, 0x4d, 0x50, 0x4c, 0x41, 0x52, 0x59,
+0x2c, 0x57, 0x00, 0xff, 0x05, 0x53, 0x45, 0x51, 0x55, 0x45, 0x4e, 0x54,
+0x49, 0x41, 0x4c, 0x20, 0x44, 0x41, 0x4d, 0x41, 0x47, 0x45, 0x53, 0x20,
+0x28, 0x1e, 0x01, 0x0f, 0x80, 0x50, 0x52, 0x4f, 0x43, 0x55, 0x52, 0x45,
+0x4d, 0xbc, 0x00, 0xf1, 0x03, 0x4f, 0x46, 0x20, 0x53, 0x55, 0x42, 0x53,
+0x54, 0x49, 0x54, 0x55, 0x54, 0x45, 0x20, 0x47, 0x4f, 0x4f, 0x44, 0x77,
+0x01, 0xd1, 0x53, 0x45, 0x52, 0x56, 0x49, 0x43, 0x45, 0x53, 0x3b, 0x20,
+0x4c, 0x4f, 0x53, 0x39, 0x01, 0x31, 0x55, 0x53, 0x45, 0x8d, 0x00, 0x41,
+0x44, 0x41, 0x54, 0x41, 0x7f, 0x00, 0x80, 0x50, 0x52, 0x4f, 0x46, 0x49,
+0x54, 0x53, 0x3b, 0x0c, 0x00, 0x41, 0x42, 0x55, 0x53, 0x49, 0x43, 0x01,
+0xf1, 0x0d, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x52, 0x55, 0x50, 0x54, 0x49,
+0x4f, 0x4e, 0x29, 0x20, 0x48, 0x4f, 0x57, 0x45, 0x56, 0x45, 0x52, 0x20,
+0x43, 0x41, 0x55, 0x53, 0x45, 0x44, 0x6c, 0x01, 0x20, 0x4f, 0x4e, 0xf4,
+0x00, 0x02, 0x3c, 0x02, 0x40, 0x45, 0x4f, 0x52, 0x59, 0x5b, 0x00, 0x23,
+0x4c, 0x49, 0x8e, 0x01, 0x90, 0x2c, 0x20, 0x57, 0x48, 0x45, 0x54, 0x48,
+0x45, 0x52, 0x5f, 0x01, 0x01, 0x36, 0x01, 0x10, 0x41, 0x0f, 0x01, 0x68,
+0x53, 0x54, 0x52, 0x49, 0x43, 0x54, 0x27, 0x00, 0x61, 0x4f, 0x52, 0x20,
+0x54, 0x4f, 0x52, 0xd9, 0x00, 0x06, 0xf0, 0x00, 0xb0, 0x20, 0x4e, 0x45,
+0x47, 0x4c, 0x49, 0x47, 0x45, 0x4e, 0x43, 0x45, 0x21, 0x00, 0x10, 0x4f,
+0x49, 0x00, 0xa0, 0x57, 0x49, 0x53, 0x45, 0x29, 0x20, 0x41, 0x52, 0x49,
+0x53, 0x21, 0x00, 0x11, 0x49, 0x7d, 0x00, 0x71, 0x20, 0x57, 0x41, 0x59,
+0x20, 0x4f, 0x55, 0xfc, 0x00, 0x00, 0xb5, 0x01, 0x31, 0x55, 0x53, 0x45,
+0xaf, 0x01, 0x1a, 0x46, 0xcf, 0x02, 0x11, 0x2c, 0xde, 0x01, 0x80, 0x20,
+0x49, 0x46, 0x20, 0x41, 0x44, 0x56, 0x49, 0xc0, 0x00, 0x03, 0x30, 0x00,
+0x53, 0x50, 0x4f, 0x53, 0x53, 0x49, 0x3f, 0x02, 0x01, 0x3f, 0x01, 0x23,
+0x43, 0x48, 0x7e, 0x01, 0x02, 0x15, 0x03, 0x70, 0x59, 0x6f, 0x75, 0x20,
+0x63, 0x61, 0x6e, 0x9b, 0x03, 0x32, 0x74, 0x61, 0x63, 0xb5, 0x04, 0xb0,
+0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x20, 0x61, 0x74, 0x20, 0x3a, 0x23,
+0x00, 0x11, 0x2d, 0xe8, 0x05, 0x03, 0x8c, 0x04, 0xd0, 0x72, 0x65, 0x70,
+0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x20, 0x3a, 0x20, 0x8a, 0x05,
+0xf6, 0x0c, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62,
+0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x43, 0x79, 0x61, 0x6e, 0x34, 0x39, 0x37,
+0x33, 0x2f, 0x6c, 0x7a, 0x34, 0x3d, 0x00, 0x60, 0x70, 0x75, 0x62, 0x6c,
+0x69, 0x63, 0x40, 0x04, 0x28, 0x75, 0x6d, 0x38, 0x00, 0xc1, 0x72, 0x6f,
+0x75, 0x70, 0x73, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x3f, 0x00,
+0x01, 0x22, 0x00, 0x32, 0x2f, 0x23, 0x21, 0x08, 0x00, 0xf0, 0x1b, 0x6c,
+0x7a, 0x34, 0x63, 0x0a, 0x2a, 0x2f, 0x0a, 0x23, 0x70, 0x72, 0x61, 0x67,
+0x6d, 0x61, 0x20, 0x6f, 0x6e, 0x63, 0x65, 0x0a, 0x0a, 0x23, 0x69, 0x66,
+0x20, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x64, 0x20, 0x28, 0x5f, 0x5f,
+0x63, 0x70, 0x6c, 0x75, 0x73, 0x04, 0x00, 0xf0, 0x08, 0x29, 0x0a, 0x65,
+0x78, 0x74, 0x65, 0x72, 0x6e, 0x20, 0x22, 0x43, 0x22, 0x20, 0x7b, 0x0a,
+0x23, 0x65, 0x6e, 0x64, 0x69, 0x66, 0x0a, 0x0a, 0xab, 0x06, 0x74, 0x2a,
+0x20, 0x6c, 0x7a, 0x34, 0x2e, 0x68, 0x2a, 0x04, 0x79, 0x73, 0x20, 0x62,
+0x6c, 0x6f, 0x63, 0x6b, 0xb2, 0x06, 0x41, 0x66, 0x75, 0x6e, 0x63, 0x9b,
+0x04, 0x11, 0x2c, 0x9c, 0x04, 0xf1, 0x02, 0x67, 0x69, 0x76, 0x65, 0x73,
+0x20, 0x66, 0x75, 0x6c, 0x6c, 0x20, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72,
+0x22, 0x01, 0x60, 0x72, 0x6f, 0x6c, 0x20, 0x74, 0x6f, 0x47, 0x00, 0x42,
+0x67, 0x72, 0x61, 0x6d, 0x37, 0x05, 0xb0, 0x2a, 0x20, 0x49, 0x66, 0x20,
+0x79, 0x6f, 0x75, 0x20, 0x6e, 0x65, 0xfa, 0x05, 0x90, 0x6f, 0x20, 0x67,
+0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x5a, 0x06, 0xc5, 0x74, 0x65, 0x72,
+0x2d, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x6e, 0x00, 0xf0,
+0x01, 0x65, 0x64, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x28, 0x72, 0x65,
+0x73, 0x70, 0x65, 0x63, 0x74, 0xfd, 0x04, 0x00, 0x25, 0x01, 0x60, 0x66,
+0x72, 0x61, 0x6d, 0x65, 0x20, 0x13, 0x00, 0x05, 0x61, 0x06, 0x20, 0x29,
+0x2c, 0x60, 0x00, 0x00, 0x90, 0x00, 0x00, 0xa4, 0x01, 0x22, 0x6c, 0x65,
+0xa0, 0x01, 0x40, 0x6c, 0x69, 0x62, 0x72, 0x8f, 0x05, 0xf1, 0x0e, 0x68,
+0x61, 0x6e, 0x64, 0x6c, 0x65, 0x20, 0x69, 0x74, 0x73, 0x20, 0x6f, 0x77,
+0x6e, 0x20, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x2c, 0x20, 0x70, 0x6c,
+0x65, 0x61, 0x73, 0x65, 0xdc, 0x06, 0x31, 0x6c, 0x7a, 0x34, 0x56, 0x00,
+0xb0, 0x2e, 0x68, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x65, 0x61, 0x64, 0x2e,
+0x50, 0x01, 0x3f, 0x0a, 0x2f, 0x2a, 0x01, 0x00, 0x12, 0x70, 0x0a, 0x2a,
+0x20, 0x20, 0x56, 0x65, 0x72, 0x20, 0x01, 0x1f, 0x0a, 0x32, 0x00, 0x13,
+0x32, 0x2f, 0x0a, 0x23, 0x9b, 0x01, 0x00, 0xd2, 0x00, 0xe0, 0x5f, 0x56,
+0x45, 0x52, 0x53, 0x49, 0x4f, 0x4e, 0x5f, 0x4d, 0x41, 0x4a, 0x4f, 0x52,
+0x5d, 0x06, 0x10, 0x31, 0x05, 0x00, 0x20, 0x2f, 0x2a, 0x09, 0x02, 0x60,
+0x20, 0x62, 0x72, 0x65, 0x61, 0x6b, 0xfc, 0x00, 0x01, 0x27, 0x01, 0x20,
+0x66, 0x61, 0xe9, 0x06, 0x8f, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x20,
+0x20, 0x48, 0x00, 0x05, 0x22, 0x49, 0x4e, 0x48, 0x00, 0x17, 0x37, 0x48,
+0x00, 0x94, 0x6e, 0x65, 0x77, 0x20, 0x28, 0x6e, 0x6f, 0x6e, 0x2d, 0x51,
+0x00, 0x18, 0x29, 0x52, 0x00, 0xbf, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c,
+0x69, 0x74, 0x69, 0x65, 0x73, 0x56, 0x00, 0x05, 0x7a, 0x52, 0x45, 0x4c,
+0x45, 0x41, 0x53, 0x45, 0x9e, 0x00, 0xf0, 0x03, 0x74, 0x77, 0x65, 0x61,
+0x6b, 0x73, 0x2c, 0x20, 0x62, 0x75, 0x67, 0x2d, 0x66, 0x69, 0x78, 0x65,
+0x73, 0x2c, 0x08, 0x08, 0x70, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70,
+0x92, 0x06, 0x0f, 0x4e, 0x00, 0x05, 0x8e, 0x4e, 0x55, 0x4d, 0x42, 0x45,
+0x52, 0x20, 0x28, 0x00, 0x01, 0x40, 0x2a, 0x31, 0x30, 0x30, 0x04, 0x00,
+0x2f, 0x20, 0x2b, 0xd5, 0x00, 0x00, 0x0e, 0x19, 0x00, 0x04, 0x98, 0x00,
+0x51, 0x29, 0x0a, 0x69, 0x6e, 0x74, 0x19, 0x00, 0x12, 0x76, 0x8b, 0x01,
+0xef, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x20, 0x28, 0x76, 0x6f, 0x69,
+0x64, 0x29, 0x3b, 0xcd, 0x01, 0x1a, 0x30, 0x54, 0x75, 0x6e, 0x72, 0x01,
+0x20, 0x70, 0x61, 0x15, 0x02, 0x3f, 0x74, 0x65, 0x72, 0xd6, 0x01, 0x16,
+0x02, 0x45, 0x03, 0x00, 0x85, 0x00, 0xc0, 0x4d, 0x45, 0x4d, 0x4f, 0x52,
+0x59, 0x5f, 0x55, 0x53, 0x41, 0x47, 0x45, 0x20, 0x04, 0x31, 0x2a, 0x20,
+0x4d, 0x78, 0x02, 0x61, 0x20, 0x75, 0x73, 0x61, 0x67, 0x65, 0x23, 0x08,
+0xf0, 0x1d, 0x75, 0x6c, 0x61, 0x20, 0x3a, 0x20, 0x4e, 0x2d, 0x3e, 0x32,
+0x5e, 0x4e, 0x20, 0x42, 0x79, 0x74, 0x65, 0x73, 0x20, 0x28, 0x65, 0x78,
+0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x20, 0x3a, 0x20, 0x31, 0x30, 0x20,
+0x2d, 0x3e, 0x20, 0x31, 0x4b, 0x42, 0x3b, 0x20, 0x31, 0x32, 0x0b, 0x00,
+0x80, 0x34, 0x4b, 0x42, 0x20, 0x3b, 0x20, 0x31, 0x36, 0x0c, 0x00, 0x20,
+0x36, 0x34, 0x18, 0x00, 0x12, 0x32, 0x23, 0x00, 0x91, 0x4d, 0x42, 0x3b,
+0x20, 0x65, 0x74, 0x63, 0x2e, 0x29, 0x66, 0x03, 0x60, 0x6e, 0x63, 0x72,
+0x65, 0x61, 0x73, 0xc0, 0x00, 0x18, 0x6d, 0x72, 0x00, 0x20, 0x69, 0x6d,
+0xd6, 0x03, 0x29, 0x65, 0x73, 0xce, 0x03, 0x10, 0x72, 0x3f, 0x03, 0x12,
+0x0a, 0xcd, 0x08, 0x4a, 0x75, 0x63, 0x65, 0x64, 0x33, 0x00, 0x00, 0x4d,
+0x03, 0x03, 0x37, 0x00, 0x00, 0x70, 0x03, 0x70, 0x65, 0x64, 0x2c, 0x20,
+0x64, 0x75, 0x65, 0xbc, 0x03, 0xc0, 0x63, 0x61, 0x63, 0x68, 0x65, 0x20,
+0x65, 0x66, 0x66, 0x65, 0x63, 0x74, 0x3f, 0x00, 0xf1, 0x05, 0x44, 0x65,
+0x66, 0x61, 0x75, 0x6c, 0x74, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20,
+0x69, 0x73, 0x20, 0x31, 0x34, 0x2c, 0x20, 0x02, 0xf0, 0x05, 0x31, 0x36,
+0x4b, 0x42, 0x2c, 0x20, 0x77, 0x68, 0x69, 0x63, 0x68, 0x20, 0x6e, 0x69,
+0x63, 0x65, 0x6c, 0x79, 0x20, 0x66, 0x89, 0x03, 0xf2, 0x02, 0x69, 0x6e,
+0x74, 0x6f, 0x20, 0x49, 0x6e, 0x74, 0x65, 0x6c, 0x20, 0x78, 0x38, 0x36,
+0x20, 0x4c, 0x31, 0x53, 0x00, 0x1c, 0x0a, 0x2f, 0x02, 0x09, 0x47, 0x01,
+0x3f, 0x31, 0x34, 0x0a, 0xc7, 0x01, 0x1a, 0x20, 0x53, 0x69, 0x4c, 0x01,
+0x24, 0x20, 0x46, 0xb3, 0x04, 0x0f, 0xc7, 0x01, 0x16, 0x05, 0x4b, 0x02,
+0x04, 0x2c, 0x01, 0x22, 0x5f, 0x64, 0xe1, 0x00, 0x60, 0x28, 0x63, 0x6f,
+0x6e, 0x73, 0x74, 0x81, 0x03, 0x23, 0x72, 0x2a, 0xeb, 0x05, 0x13, 0x2c,
+0x0e, 0x00, 0x50, 0x64, 0x65, 0x73, 0x74, 0x2c, 0xd8, 0x00, 0x03, 0x18,
+0x00, 0x42, 0x53, 0x69, 0x7a, 0x65, 0x10, 0x00, 0x70, 0x6d, 0x61, 0x78,
+0x44, 0x65, 0x73, 0x74, 0x11, 0x00, 0x25, 0x29, 0x3b, 0x5b, 0x00, 0x25,
+0x64, 0x65, 0x5d, 0x00, 0x5f, 0x73, 0x61, 0x66, 0x65, 0x20, 0x5b, 0x00,
+0x12, 0x06, 0x1c, 0x05, 0x0b, 0x5f, 0x00, 0x0a, 0x19, 0x00, 0x02, 0xef,
+0x02, 0x1f, 0x0a, 0xc2, 0x00, 0x02, 0x12, 0x29, 0xae, 0x06, 0x24, 0x20,
+0x43, 0x32, 0x00, 0x36, 0x73, 0x20, 0x27, 0xb2, 0x00, 0x31, 0x27, 0x20,
+0x62, 0x89, 0x02, 0x44, 0x66, 0x72, 0x6f, 0x6d, 0xd2, 0x05, 0x03, 0x1f,
+0x00, 0x11, 0x27, 0x37, 0x00, 0x01, 0xb9, 0x01, 0xe0, 0x61, 0x6c, 0x72,
+0x65, 0x61, 0x64, 0x79, 0x20, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0xd3,
+0x0b, 0x10, 0x27, 0xa4, 0x00, 0x14, 0x27, 0x32, 0x00, 0x00, 0x94, 0x0b,
+0x57, 0x69, 0x7a, 0x65, 0x20, 0x27, 0xfb, 0x00, 0x29, 0x27, 0x2e, 0x77,
+0x00, 0x00, 0x7e, 0x02, 0xa3, 0x69, 0x73, 0x20, 0x67, 0x75, 0x61, 0x72,
+0x61, 0x6e, 0x74, 0x13, 0x06, 0x40, 0x73, 0x75, 0x63, 0x63, 0x0b, 0x00,
+0x2a, 0x69, 0x66, 0x3b, 0x00, 0x39, 0x20, 0x3e, 0x3d, 0x8f, 0x01, 0x66,
+0x42, 0x6f, 0x75, 0x6e, 0x64, 0x28, 0xb6, 0x00, 0x12, 0x29, 0x5c, 0x00,
+0xf0, 0x11, 0x49, 0x74, 0x20, 0x61, 0x6c, 0x73, 0x6f, 0x20, 0x72, 0x75,
+0x6e, 0x73, 0x20, 0x66, 0x61, 0x73, 0x74, 0x65, 0x72, 0x2c, 0x20, 0x73,
+0x6f, 0x20, 0x69, 0x74, 0x27, 0x73, 0x20, 0x61, 0x20, 0x72, 0x26, 0x01,
+0x30, 0x6d, 0x65, 0x6e, 0x03, 0x0b, 0x30, 0x73, 0x65, 0x74, 0x51, 0x06,
+0x03, 0x38, 0x00, 0x12, 0x66, 0x64, 0x0b, 0x03, 0xdb, 0x06, 0x00, 0xf8,
+0x02, 0x26, 0x6e, 0x6f, 0x6d, 0x01, 0x05, 0x01, 0x01, 0x03, 0xfd, 0x00,
+0x40, 0x20, 0x6d, 0x6f, 0x72, 0x5e, 0x06, 0x29, 0x6d, 0x69, 0xfa, 0x00,
+0x41, 0x64, 0x67, 0x65, 0x74, 0x4e, 0x09, 0x09, 0x62, 0x03, 0xf2, 0x04,
+0x73, 0x74, 0x6f, 0x70, 0x73, 0x20, 0x2a, 0x69, 0x6d, 0x6d, 0x65, 0x64,
+0x69, 0x61, 0x74, 0x65, 0x6c, 0x79, 0x2a, 0x3a, 0x07, 0x09, 0x72, 0x00,
+0x30, 0x72, 0x65, 0x73, 0x3f, 0x03, 0x72, 0x69, 0x73, 0x20, 0x7a, 0x65,
+0x72, 0x6f, 0x96, 0x00, 0x10, 0x41, 0xb4, 0x00, 0x00, 0x15, 0x02, 0x50,
+0x65, 0x71, 0x75, 0x65, 0x6e, 0x0e, 0x02, 0x03, 0x6b, 0x00, 0x00, 0x62,
+0x07, 0x21, 0x65, 0x6e, 0x2e, 0x00, 0x21, 0x6e, 0x6f, 0x74, 0x03, 0x22,
+0x69, 0x64, 0x33, 0x00, 0x10, 0x54, 0x46, 0x0c, 0x05, 0x55, 0x00, 0x90,
+0x6e, 0x65, 0x76, 0x65, 0x72, 0x20, 0x77, 0x72, 0x69, 0xd1, 0x01, 0x7a,
+0x6f, 0x75, 0x74, 0x73, 0x69, 0x64, 0x65, 0xa9, 0x01, 0x60, 0x2c, 0x20,
+0x6e, 0x6f, 0x72, 0x20, 0xcc, 0x01, 0x06, 0x20, 0x00, 0x04, 0xec, 0x00,
+0x02, 0x22, 0x00, 0x05, 0xf0, 0x0c, 0x07, 0xd6, 0x02, 0xe0, 0x20, 0x20,
+0x3a, 0x20, 0x4d, 0x61, 0x78, 0x20, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72,
+0x04, 0x01, 0x05, 0xf7, 0x03, 0x01, 0xb3, 0x03, 0xe5, 0x41, 0x58, 0x5f,
+0x49, 0x4e, 0x50, 0x55, 0x54, 0x5f, 0x56, 0x41, 0x4c, 0x55, 0x45, 0x41,
+0x00, 0x07, 0xd1, 0x01, 0x22, 0x20, 0x3a, 0x33, 0x08, 0x20, 0x6f, 0x72,
+0x64, 0x05, 0x42, 0x74, 0x69, 0x61, 0x6c, 0x30, 0x02, 0x25, 0x6f, 0x66,
+0x74, 0x02, 0x02, 0xa7, 0x00, 0x12, 0x28, 0x3a, 0x04, 0x01, 0x4c, 0x0d,
+0x2e, 0x62, 0x65, 0x78, 0x02, 0x15, 0x29, 0x5e, 0x00, 0x81, 0x72, 0x65,
+0x74, 0x75, 0x72, 0x6e, 0x20, 0x3a, 0x58, 0x01, 0x12, 0x6e, 0xfb, 0x05,
+0x23, 0x6f, 0x66, 0xce, 0x02, 0x00, 0x04, 0x01, 0x32, 0x74, 0x65, 0x6e,
+0xc0, 0x01, 0x0b, 0x62, 0x00, 0xe0, 0x6e, 0x65, 0x63, 0x65, 0x73, 0x73,
+0x61, 0x72, 0x69, 0x6c, 0x79, 0x20, 0x3c, 0x3d, 0xa6, 0x00, 0x52, 0x4f,
+0x75, 0x74, 0x70, 0x75, 0xaf, 0x03, 0x29, 0x0a, 0x20, 0x01, 0x00, 0x40,
+0x6f, 0x72, 0x20, 0x30, 0x9d, 0x02, 0x09, 0x11, 0x09, 0x6f, 0x61, 0x69,
+0x6c, 0x73, 0x0a, 0x0a, 0xd3, 0x03, 0x00, 0x05, 0x6b, 0x03, 0x0a, 0x9d,
+0x03, 0x20, 0x20, 0x3a, 0x2a, 0x01, 0x00, 0xa7, 0x00, 0x72, 0x70, 0x72,
+0x65, 0x63, 0x69, 0x73, 0x65, 0x0c, 0x01, 0x04, 0x01, 0x01, 0x29, 0x74,
+0x68, 0x03, 0x09, 0x01, 0x82, 0x09, 0x02, 0x86, 0x01, 0x0e, 0xe9, 0x03,
+0x07, 0x4c, 0x00, 0x04, 0x3f, 0x00, 0x00, 0xd6, 0x00, 0x22, 0x69, 0x6e,
+0x08, 0x0e, 0x04, 0xe5, 0x01, 0x0f, 0x45, 0x01, 0x0c, 0x2f, 0x2e, 0x0a,
+0x41, 0x01, 0x0e, 0x17, 0x64, 0x78, 0x00, 0x02, 0x46, 0x01, 0x0e, 0x68,
+0x00, 0x0e, 0x4b, 0x01, 0x0f, 0x99, 0x04, 0x00, 0x0a, 0x51, 0x01, 0x1f,
+0x49, 0xb0, 0x00, 0x01, 0x04, 0xd8, 0x02, 0xd1, 0x6c, 0x61, 0x72, 0x67,
+0x65, 0x20, 0x65, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x2c, 0x82, 0x00, 0x10,
+0x64, 0xd5, 0x06, 0x41, 0x77, 0x69, 0x6c, 0x6c, 0x56, 0x03, 0x01, 0x46,
+0x03, 0x11, 0x6f, 0xac, 0x01, 0x92, 0x20, 0x61, 0x6e, 0x20, 0x65, 0x72,
+0x72, 0x6f, 0x72, 0x04, 0x10, 0x5d, 0x28, 0x3c, 0x30, 0x29, 0x2e, 0x6a,
+0x00, 0x01, 0x26, 0x01, 0x02, 0x9e, 0x0b, 0x60, 0x73, 0x74, 0x72, 0x65,
+0x61, 0x6d, 0x69, 0x00, 0x50, 0x64, 0x65, 0x74, 0x65, 0x63, 0xc3, 0x02,
+0x30, 0x6d, 0x61, 0x6c, 0x94, 0x07, 0x00, 0xe4, 0x06, 0x09, 0x9a, 0x03,
+0x06, 0x6f, 0x00, 0x05, 0x82, 0x00, 0x00, 0x78, 0x00, 0x03, 0x2e, 0x01,
+0xa3, 0x61, 0x20, 0x6e, 0x65, 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0xc3,
+0x03, 0x0b, 0x77, 0x00, 0x0a, 0x91, 0x03, 0x11, 0x69, 0x84, 0x0f, 0x03,
+0x71, 0x00, 0x30, 0x61, 0x67, 0x61, 0x6c, 0x0a, 0x05, 0x33, 0x05, 0xf0,
+0x01, 0x76, 0x65, 0x72, 0x66, 0x6c, 0x6f, 0x77, 0x20, 0x65, 0x78, 0x70,
+0x6c, 0x6f, 0x69, 0x74, 0x73, 0xdd, 0x05, 0x31, 0x63, 0x6c, 0x75, 0x72,
+0x00, 0x92, 0x6d, 0x61, 0x6c, 0x69, 0x63, 0x69, 0x6f, 0x75, 0x73, 0x12,
+0x0b, 0x7c, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0xe3, 0x00, 0x1f,
+0x74, 0xf2, 0x03, 0x03, 0x03, 0x23, 0x01, 0x0c, 0xf2, 0x03, 0x06, 0x21,
+0x00, 0x26, 0x69, 0x6e, 0x20, 0x00, 0x02, 0xf8, 0x0a, 0x0f, 0x65, 0x07,
+0x19, 0x50, 0x41, 0x64, 0x76, 0x61, 0x6e, 0x3b, 0x08, 0x0e, 0x67, 0x07,
+0x0f, 0x04, 0x0b, 0x19, 0x06, 0x36, 0x04, 0x44, 0x53, 0x49, 0x5a, 0x45,
+0xd4, 0x00, 0x51, 0x30, 0x78, 0x37, 0x45, 0x30, 0x01, 0x00, 0x02, 0x73,
+0x0a, 0xd3, 0x32, 0x20, 0x31, 0x31, 0x33, 0x20, 0x39, 0x32, 0x39, 0x20,
+0x32, 0x31, 0x36, 0x9c, 0x02, 0x0b, 0xaf, 0x0a, 0x31, 0x43, 0x4f, 0x4d,
+0x69, 0x10, 0x70, 0x42, 0x4f, 0x55, 0x4e, 0x44, 0x28, 0x69, 0x18, 0x03,
+0xe4, 0x29, 0x20, 0x20, 0x28, 0x28, 0x75, 0x6e, 0x73, 0x69, 0x67, 0x6e,
+0x65, 0x64, 0x29, 0x14, 0x00, 0x26, 0x3e, 0x20, 0x14, 0x00, 0x0f, 0x82,
+0x00, 0x00, 0x64, 0x3f, 0x20, 0x30, 0x20, 0x3a, 0x20, 0x2d, 0x00, 0x33,
+0x2b, 0x20, 0x28, 0x0b, 0x00, 0x40, 0x2f, 0x32, 0x35, 0x35, 0x10, 0x00,
+0x3d, 0x31, 0x36, 0x29, 0x65, 0x07, 0x02, 0x98, 0x06, 0x04, 0xf7, 0x03,
+0x14, 0x50, 0x46, 0x0d, 0x00, 0x51, 0x02, 0x72, 0x6d, 0x61, 0x78, 0x69,
+0x6d, 0x75, 0x6d, 0xa8, 0x03, 0x01, 0xf8, 0x12, 0x00, 0xcc, 0x0c, 0x08,
+0x49, 0x04, 0x34, 0x6d, 0x61, 0x79, 0xac, 0x01, 0x10, 0x69, 0x5a, 0x02,
+0x40, 0x22, 0x77, 0x6f, 0x72, 0x11, 0x08, 0xf2, 0x00, 0x61, 0x73, 0x65,
+0x22, 0x20, 0x73, 0x63, 0x65, 0x6e, 0x61, 0x72, 0x69, 0x6f, 0x20, 0x28,
+0xae, 0x01, 0x01, 0x08, 0x02, 0x08, 0xa5, 0x06, 0x33, 0x69, 0x62, 0x6c,
+0x5e, 0x03, 0x0f, 0x74, 0x02, 0x00, 0x22, 0x69, 0x6d, 0x95, 0x03, 0x61,
+0x75, 0x73, 0x65, 0x66, 0x75, 0x6c, 0x99, 0x09, 0x03, 0xe9, 0x09, 0x03,
+0x05, 0x04, 0x00, 0x2a, 0x00, 0x50, 0x70, 0x75, 0x72, 0x70, 0x6f, 0x0f,
+0x08, 0x1f, 0x28, 0x94, 0x03, 0x00, 0x16, 0x73, 0x66, 0x07, 0x5f, 0x4d,
+0x61, 0x63, 0x72, 0x6f, 0x6b, 0x01, 0x00, 0x10, 0x29, 0x6c, 0x00, 0x01,
+0x80, 0x07, 0x05, 0x69, 0x12, 0x11, 0x66, 0x92, 0x03, 0x41, 0x6d, 0x70,
+0x69, 0x6c, 0x4d, 0x00, 0x70, 0x2d, 0x74, 0x69, 0x6d, 0x65, 0x20, 0x65,
+0x2e, 0x06, 0x02, 0x5d, 0x00, 0x6f, 0x28, 0x73, 0x74, 0x61, 0x63, 0x6b,
+0x8c, 0x00, 0x00, 0x00, 0x39, 0x00, 0x03, 0x0b, 0x0b, 0x03, 0x76, 0x00,
+0x36, 0x4e, 0x6f, 0x74, 0x38, 0x01, 0x0f, 0xd6, 0x08, 0x01, 0x05, 0xae,
+0x07, 0x02, 0xf9, 0x07, 0x51, 0x20, 0x77, 0x68, 0x65, 0x6e, 0x5e, 0x04,
+0x08, 0xc3, 0x00, 0x00, 0xa3, 0x00, 0x0f, 0x4c, 0x08, 0x03, 0x2a, 0x72,
+0x63, 0xa0, 0x04, 0x01, 0x67, 0x01, 0x04, 0xee, 0x06, 0x1f, 0x6d, 0xee,
+0x06, 0x11, 0x00, 0x36, 0x02, 0x0e, 0x8f, 0x06, 0x04, 0xf8, 0x01, 0x03,
+0xda, 0x01, 0x02, 0x85, 0x00, 0x0f, 0xdf, 0x01, 0x06, 0x0f, 0x70, 0x06,
+0x00, 0x10, 0x2c, 0x71, 0x06, 0x26, 0x69, 0x6e, 0x3d, 0x00, 0x53, 0x73,
+0x20, 0x74, 0x6f, 0x6f, 0x1e, 0x05, 0x3f, 0x28, 0x20, 0x3e, 0x86, 0x00,
+0x00, 0x10, 0x29, 0xc5, 0x03, 0x0c, 0xc3, 0x0a, 0x02, 0xe8, 0x00, 0x00,
+0x16, 0x00, 0x05, 0xdb, 0x00, 0x0f, 0x27, 0x0a, 0x01, 0x00, 0x3e, 0x01,
+0x05, 0xc2, 0x02, 0x10, 0x53, 0x6a, 0x0f, 0x2f, 0x61, 0x73, 0x73, 0x01,
+0x04, 0x00, 0xf6, 0x0d, 0x11, 0x74, 0xb6, 0x01, 0x21, 0x77, 0x73, 0xbe,
+0x09, 0x41, 0x65, 0x6c, 0x65, 0x63, 0x8c, 0x05, 0x81, 0x22, 0x61, 0x63,
+0x63, 0x65, 0x6c, 0x65, 0x72, 0xcd, 0x01, 0x84, 0x22, 0x20, 0x66, 0x61,
+0x63, 0x74, 0x6f, 0x72, 0xa3, 0x08, 0x12, 0x65, 0xbc, 0x00, 0x12, 0x72,
+0x44, 0x11, 0x07, 0x29, 0x00, 0x02, 0x59, 0x01, 0x03, 0x80, 0x05, 0x02,
+0xc5, 0x01, 0x01, 0x23, 0x00, 0x04, 0x24, 0x17, 0x04, 0x70, 0x00, 0x22,
+0x73, 0x6f, 0xdf, 0x0f, 0x00, 0x56, 0x06, 0x19, 0x72, 0x30, 0x07, 0x01,
+0xc4, 0x14, 0x02, 0x0a, 0x0a, 0x01, 0xf2, 0x09, 0xa0, 0x74, 0x72, 0x61,
+0x64, 0x65, 0x2d, 0x6f, 0x66, 0x66, 0x2e, 0x1e, 0x05, 0x00, 0xcf, 0x0c,
+0x31, 0x62, 0x65, 0x20, 0x2a, 0x04, 0x53, 0x74, 0x75, 0x6e, 0x65, 0x64,
+0xb9, 0x16, 0x42, 0x65, 0x61, 0x63, 0x68, 0x7b, 0x0a, 0x20, 0x73, 0x73,
+0xca, 0x05, 0x02, 0xe0, 0x01, 0x02, 0xc5, 0x02, 0x00, 0x7e, 0x05, 0x10,
+0x72, 0x82, 0x06, 0x71, 0x6c, 0x79, 0x20, 0x2b, 0x7e, 0x33, 0x25, 0xe8,
+0x00, 0x00, 0x0b, 0x0d, 0x03, 0xa4, 0x09, 0x1f, 0x6e, 0xc2, 0x00, 0x00,
+0x00, 0x37, 0x07, 0x35, 0x22, 0x31, 0x22, 0x9a, 0x07, 0x03, 0x45, 0x01,
+0x7f, 0x72, 0x65, 0x67, 0x75, 0x6c, 0x61, 0x72, 0x4d, 0x01, 0x04, 0x01,
+0x4f, 0x00, 0x10, 0x56, 0x3f, 0x00, 0x10, 0x73, 0x3c, 0x07, 0x12, 0x30,
+0x79, 0x06, 0x11, 0x62, 0x4a, 0x12, 0x20, 0x6c, 0x61, 0x60, 0x05, 0xb0,
+0x62, 0x79, 0x20, 0x41, 0x43, 0x43, 0x45, 0x4c, 0x45, 0x52, 0x41, 0x8a,
+0x13, 0xc1, 0x5f, 0x44, 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x20, 0x28,
+0x73, 0x65, 0xc2, 0x10, 0x34, 0x2e, 0x63, 0x29, 0xeb, 0x07, 0x00, 0x81,
+0x0d, 0x1f, 0x2e, 0x05, 0x02, 0x01, 0x01, 0xdf, 0x01, 0x1f, 0x20, 0xc6,
+0x0c, 0x2d, 0x02, 0x11, 0x00, 0x08, 0xf9, 0x00, 0x00, 0x4a, 0x02, 0x0f,
+0x4b, 0x02, 0x02, 0x9a, 0x5f, 0x65, 0x78, 0x74, 0x53, 0x74, 0x61, 0x74,
+0x65, 0x54, 0x02, 0x0f, 0x52, 0x12, 0x01, 0x30, 0x2c, 0x20, 0x6a, 0xa2,
+0x08, 0x22, 0x75, 0x73, 0x64, 0x07, 0x12, 0x20, 0xa6, 0x12, 0x38, 0x61,
+0x6c, 0x6c, 0x68, 0x0c, 0x03, 0x2b, 0x04, 0x41, 0x73, 0x70, 0x61, 0x63,
+0x89, 0x0e, 0x20, 0x73, 0x74, 0x8c, 0x0b, 0x0a, 0x71, 0x0b, 0x32, 0x61,
+0x74, 0x65, 0x9e, 0x01, 0x22, 0x55, 0x73, 0x13, 0x06, 0x00, 0x38, 0x03,
+0x24, 0x6f, 0x66, 0x87, 0x00, 0xf4, 0x01, 0x74, 0x6f, 0x20, 0x6b, 0x6e,
+0x6f, 0x77, 0x20, 0x68, 0x6f, 0x77, 0x20, 0x6d, 0x75, 0x63, 0x68, 0x54,
+0x00, 0x06, 0x20, 0x09, 0x03, 0x6d, 0x00, 0x02, 0xcd, 0x0b, 0x00, 0xee,
+0x07, 0x04, 0x13, 0x00, 0x92, 0x20, 0x69, 0x74, 0x20, 0x6f, 0x6e, 0x20,
+0x38, 0x2d, 0x7a, 0x06, 0x10, 0x62, 0x53, 0x03, 0x20, 0x61, 0x72, 0x34,
+0x11, 0x33, 0x28, 0x75, 0x73, 0xa9, 0x07, 0x30, 0x6c, 0x6f, 0x63, 0x65,
+0x00, 0x40, 0x79, 0x70, 0x69, 0x63, 0xbc, 0x00, 0x15, 0x29, 0xf7, 0x02,
+0x24, 0x6e, 0x2c, 0x19, 0x05, 0x00, 0x47, 0x00, 0x40, 0x61, 0x73, 0x20,
+0x27, 0x9a, 0x10, 0x12, 0x2a, 0xb1, 0x00, 0x11, 0x27, 0x56, 0x0f, 0x0f,
+0x16, 0x01, 0x00, 0x09, 0xc7, 0x01, 0x08, 0xc9, 0x00, 0x03, 0xd7, 0x10,
+0x04, 0x4f, 0x0e, 0x0f, 0x76, 0x01, 0x03, 0x27, 0x20, 0x28, 0x64, 0x00,
+0x2f, 0x2c, 0x20, 0xf8, 0x01, 0x11, 0x05, 0x1e, 0x04, 0x0f, 0xf7, 0x01,
+0x25, 0x13, 0x64, 0x2f, 0x00, 0x05, 0xf2, 0x01, 0x10, 0x52, 0x96, 0x08,
+0x12, 0x73, 0x03, 0x19, 0x60, 0x6c, 0x6f, 0x67, 0x69, 0x63, 0x2c, 0xcc,
+0x02, 0x05, 0xed, 0x00, 0x00, 0xee, 0x01, 0x12, 0x73, 0x8a, 0x01, 0x01,
+0xd6, 0x06, 0x52, 0x61, 0x73, 0x20, 0x70, 0x6f, 0xd1, 0x06, 0x02, 0x87,
+0x0e, 0x0b, 0x93, 0x0c, 0x0f, 0x87, 0x0e, 0x09, 0x0a, 0xdc, 0x0b, 0x05,
+0x87, 0x0e, 0x10, 0x74, 0x71, 0x04, 0x1b, 0x74, 0x8a, 0x0e, 0x0a, 0x2d,
+0x0d, 0x21, 0x65, 0x69, 0x2e, 0x19, 0x16, 0x63, 0x16, 0x0f, 0x00, 0xaf,
+0x00, 0x57, 0x65, 0x6e, 0x74, 0x69, 0x72, 0x15, 0x0d, 0x05, 0x7b, 0x0d,
+0x00, 0x7f, 0x00, 0x03, 0x66, 0x00, 0x22, 0x69, 0x66, 0x61, 0x0e, 0x09,
+0xb0, 0x0a, 0x13, 0x0a, 0xbf, 0x05, 0x10, 0x66, 0xc6, 0x03, 0x0a, 0x1d,
+0x0f, 0x00, 0x63, 0x00, 0x20, 0x6c, 0x65, 0x0a, 0x0e, 0x02, 0x7f, 0x04,
+0x0f, 0xfd, 0x00, 0x13, 0x06, 0xed, 0x09, 0x16, 0x2a, 0x9a, 0x03, 0x55,
+0x50, 0x74, 0x72, 0x20, 0x3a, 0x2a, 0x04, 0x02, 0x73, 0x1b, 0x02, 0x4a,
+0x0f, 0x41, 0x69, 0x6e, 0x64, 0x69, 0xb2, 0x02, 0x01, 0xe6, 0x02, 0x34,
+0x61, 0x6e, 0x79, 0x0a, 0x0d, 0x42, 0x68, 0x65, 0x72, 0x65, 0xf2, 0x0d,
+0x0a, 0x5c, 0x01, 0x28, 0x74, 0x6f, 0xac, 0x00, 0x0b, 0x5b, 0x0a, 0x08,
+0x01, 0x00, 0x36, 0x4e, 0x65, 0x77, 0x02, 0x07, 0x0b, 0xf2, 0x0b, 0x23,
+0x6f, 0x6c, 0x1e, 0x07, 0x1e, 0x2e, 0x09, 0x07, 0x2f, 0x4e, 0x62, 0x8d,
+0x0d, 0x01, 0x0f, 0x86, 0x0d, 0x04, 0x0a, 0xb1, 0x01, 0x0f, 0x87, 0x0d,
+0x17, 0x0e, 0xf3, 0x04, 0x06, 0x90, 0x02, 0x0f, 0xf7, 0x04, 0x12, 0x29,
+0x2a, 0x20, 0x5e, 0x01, 0x02, 0xf3, 0x02, 0x0b, 0x8e, 0x00, 0x07, 0xf5,
+0x02, 0x2f, 0x64, 0x65, 0x39, 0x07, 0x03, 0x8a, 0x6f, 0x72, 0x69, 0x67,
+0x69, 0x6e, 0x61, 0x6c, 0xa4, 0x0d, 0x04, 0x16, 0x00, 0x04, 0x00, 0x10,
+0x30, 0x72, 0x65, 0x66, 0xbe, 0x04, 0x27, 0x75, 0x6e, 0x5d, 0x0d, 0x00,
+0xb1, 0x02, 0x0f, 0x90, 0x0d, 0x0f, 0x06, 0xc1, 0x01, 0x07, 0xd6, 0x0c,
+0x04, 0x87, 0x0d, 0x23, 0x69, 0x6e, 0xfb, 0x1b, 0x6c, 0x77, 0x6f, 0x72,
+0x64, 0x73, 0x2c, 0x52, 0x0e, 0x01, 0xcb, 0x09, 0x0f, 0x1e, 0x0d, 0x72,
+0x1e, 0x44, 0x68, 0x0a, 0x0f, 0xa5, 0x0e, 0x07, 0x42, 0x20, 0x49, 0x74,
+0x73, 0xcf, 0x03, 0x05, 0x24, 0x00, 0x42, 0x20, 0x6d, 0x69, 0x6e, 0x5d,
+0x09, 0x38, 0x66, 0x20, 0x27, 0x73, 0x01, 0x03, 0xc6, 0x12, 0x02, 0x6f,
+0x00, 0x10, 0x6e, 0x3a, 0x0a, 0x1b, 0x3a, 0xef, 0x03, 0x00, 0x73, 0x0f,
+0x23, 0x79, 0x20, 0x5a, 0x18, 0x04, 0x02, 0x06, 0x07, 0xd0, 0x05, 0x00,
+0x81, 0x0a, 0x20, 0x70, 0x72, 0x94, 0x18, 0x12, 0x6c, 0xd0, 0x1d, 0x2c,
+0x65, 0x64, 0x99, 0x18, 0x2a, 0x2e, 0x0a, 0x7d, 0x0d, 0x00, 0xfe, 0x0a,
+0x46, 0x20, 0x62, 0x69, 0x74, 0xbc, 0x08, 0x3f, 0x61, 0x6e, 0x20, 0x17,
+0x10, 0x02, 0x09, 0x3a, 0x00, 0x30, 0x48, 0x6f, 0x77, 0x20, 0x05, 0x10,
+0x2c, 0x15, 0x06, 0x32, 0x64, 0x6f, 0x65, 0xfc, 0x0e, 0x04, 0x29, 0x06,
+0x00, 0xb9, 0x03, 0x03, 0x33, 0x0e, 0x01, 0xd9, 0x1d, 0x03, 0x34, 0x0e,
+0x11, 0x69, 0x86, 0x04, 0x22, 0x69, 0x6f, 0x1e, 0x07, 0x05, 0xf8, 0x03,
+0x01, 0x42, 0x04, 0x03, 0xbe, 0x01, 0x16, 0x28, 0x34, 0x0e, 0x01, 0xd2,
+0x05, 0x0a, 0x75, 0x00, 0x00, 0x1a, 0x07, 0x1a, 0x74, 0x28, 0x0c, 0x60,
+0x6e, 0x20, 0x74, 0x72, 0x75, 0x73, 0xed, 0x01, 0x71, 0x65, 0x6e, 0x76,
+0x69, 0x72, 0x6f, 0x6e, 0xbe, 0x17, 0x61, 0x6f, 0x6e, 0x6c, 0x79, 0x20,
+0x28, 0x59, 0x00, 0x22, 0x74, 0x6f, 0xe5, 0x01, 0x01, 0x4d, 0x02, 0x04,
+0x23, 0x14, 0x15, 0x61, 0x36, 0x00, 0x02, 0x3d, 0x02, 0x19, 0x29, 0xb0,
+0x06, 0x2f, 0x64, 0x65, 0x79, 0x08, 0x20, 0x08, 0xc9, 0x01, 0x2f, 0x29,
+0x3b, 0x6b, 0x03, 0x01, 0x00, 0x46, 0x01, 0x13, 0x5f, 0x39, 0x12, 0x05,
+0x73, 0x03, 0x0a, 0xcf, 0x05, 0x06, 0x2e, 0x00, 0x2d, 0x20, 0x61, 0x4f,
+0x11, 0x06, 0x19, 0x06, 0x0a, 0x9e, 0x10, 0x10, 0x27, 0xcc, 0x1b, 0x01,
+0xb8, 0x1b, 0x00, 0x43, 0x00, 0x0e, 0xf7, 0x14, 0x0e, 0xf4, 0x10, 0x0d,
+0x6a, 0x06, 0x0f, 0xf4, 0x10, 0x00, 0x05, 0x6f, 0x06, 0x07, 0x38, 0x03,
+0x11, 0x74, 0x65, 0x02, 0x26, 0x74, 0x6f, 0x3c, 0x03, 0x06, 0x0d, 0x07,
+0x24, 0x6f, 0x70, 0x4e, 0x0a, 0x52, 0x61, 0x73, 0x20, 0x73, 0x6f, 0x08,
+0x00, 0x03, 0xc3, 0x06, 0x06, 0x9b, 0x12, 0x90, 0x27, 0x20, 0x68, 0x61,
+0x73, 0x20, 0x62, 0x65, 0x65, 0x3d, 0x14, 0x00, 0x3b, 0x17, 0x03, 0xaf,
+0x08, 0x10, 0x72, 0xc9, 0x17, 0x01, 0x28, 0x20, 0x18, 0x65, 0x1f, 0x05,
+0x00, 0x7a, 0x0d, 0x0f, 0xe8, 0x11, 0x14, 0x00, 0xb9, 0x0d, 0x04, 0x57,
+0x20, 0x0f, 0xe5, 0x11, 0x2b, 0x12, 0x4e, 0x7a, 0x03, 0x01, 0x69, 0x02,
+0x03, 0x6a, 0x00, 0x03, 0x84, 0x0b, 0x1f, 0x3c, 0xd1, 0x00, 0x01, 0x6f,
+0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x01, 0x13, 0x02, 0x07, 0x7d, 0x02,
+0x40, 0x62, 0x65, 0x20, 0x73, 0x67, 0x09, 0x2b, 0x65, 0x72, 0x4e, 0x04,
+0x65, 0x41, 0x6c, 0x77, 0x61, 0x79, 0x73, 0x80, 0x1c, 0x0c, 0xf9, 0x06,
+0x00, 0xf8, 0x06, 0x03, 0xdf, 0x00, 0x0f, 0x1c, 0x12, 0x81, 0x0f, 0xbb,
+0x11, 0x03, 0x1c, 0x66, 0xbe, 0x11, 0x00, 0x60, 0x00, 0x02, 0x2b, 0x00,
+0x0a, 0xc4, 0x11, 0x2a, 0x6f, 0x66, 0xc7, 0x11, 0x03, 0x91, 0x04, 0x06,
+0x65, 0x06, 0x0e, 0x79, 0x12, 0x0f, 0x55, 0x12, 0x03, 0x0e, 0xbf, 0x03,
+0x0d, 0x73, 0x03, 0x0f, 0xab, 0x18, 0x27, 0x0c, 0xf4, 0x01, 0x0f, 0xc1,
+0x18, 0x0a, 0x0e, 0x85, 0x12, 0x0f, 0xf3, 0x19, 0x11, 0x01, 0xbe, 0x01,
+0x00, 0x8a, 0x01, 0x08, 0x69, 0x18, 0x0f, 0x9b, 0x12, 0x00, 0x0f, 0xa4,
+0x12, 0x21, 0x60, 0x53, 0x54, 0x52, 0x45, 0x41, 0x4d, 0x62, 0x0f, 0xdc,
+0x5f, 0x55, 0x36, 0x34, 0x20, 0x28, 0x28, 0x31, 0x20, 0x3c, 0x3c, 0x20,
+0x28, 0xa8, 0x1a, 0x30, 0x2d, 0x33, 0x29, 0x21, 0x12, 0x2f, 0x34, 0x29,
+0x3d, 0x00, 0x04, 0x01, 0xfe, 0x01, 0x1f, 0x28, 0x51, 0x00, 0x00, 0x22,
+0x2a, 0x20, 0xe1, 0x0b, 0x60, 0x28, 0x6c, 0x6f, 0x6e, 0x67, 0x20, 0x05,
+0x00, 0x27, 0x29, 0x29, 0x53, 0x1c, 0x02, 0x9a, 0x02, 0x11, 0x5f, 0x71,
+0x1b, 0x20, 0x69, 0x6e, 0x92, 0x02, 0x02, 0x9a, 0x03, 0x81, 0x73, 0x74,
+0x72, 0x75, 0x63, 0x74, 0x75, 0x72, 0x11, 0x0d, 0x20, 0x74, 0x72, 0x52,
+0x11, 0x02, 0x7a, 0x06, 0x03, 0xcc, 0x02, 0x01, 0x7d, 0x1f, 0x20, 0x69,
+0x6d, 0xbe, 0x10, 0x30, 0x61, 0x6e, 0x74, 0x8f, 0x08, 0x32, 0x6e, 0x69,
+0x74, 0x96, 0x03, 0x06, 0x3b, 0x00, 0x04, 0xda, 0x0a, 0x12, 0x62, 0x2f,
+0x02, 0x31, 0x66, 0x69, 0x72, 0x8c, 0x0d, 0x30, 0x65, 0x20, 0x21, 0x3e,
+0x00, 0x03, 0x44, 0x07, 0x29, 0x6f, 0x6e, 0x8d, 0x0d, 0x82, 0x64, 0x69,
+0x72, 0x65, 0x63, 0x74, 0x6c, 0x79, 0x3f, 0x03, 0x05, 0x4b, 0x00, 0x12,
+0x69, 0xe8, 0x1f, 0x00, 0xf4, 0x25, 0x00, 0x78, 0x0c, 0x02, 0x08, 0x0d,
+0x53, 0x20, 0x6c, 0x69, 0x6e, 0x6b, 0xc3, 0x1f, 0x00, 0x52, 0x00, 0x06,
+0x7c, 0x03, 0x04, 0x2c, 0x00, 0x02, 0x42, 0x0d, 0x60, 0x6c, 0x69, 0x62,
+0x6c, 0x7a, 0x34, 0xf3, 0x04, 0x59, 0x61, 0x20, 0x44, 0x4c, 0x4c, 0xa7,
+0x1f, 0x20, 0x62, 0x65, 0x21, 0x15, 0x01, 0x7d, 0x02, 0x00, 0x6c, 0x00,
+0x01, 0x35, 0x13, 0x66, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0xb7, 0x1f,
+0x00, 0x0f, 0x14, 0x73, 0x74, 0x79, 0x70, 0x65, 0x64, 0x65, 0x66, 0x93,
+0x00, 0x35, 0x20, 0x7b, 0x20, 0x50, 0x01, 0x20, 0x20, 0x74, 0x63, 0x20,
+0x1e, 0x5b, 0x7c, 0x01, 0x49, 0x5d, 0x3b, 0x20, 0x7d, 0x65, 0x01, 0x27,
+0x3b, 0x0a, 0x7a, 0x01, 0x52, 0x72, 0x65, 0x73, 0x65, 0x74, 0x5b, 0x02,
+0x00, 0x13, 0x00, 0x0e, 0x3e, 0x07, 0x22, 0x74, 0x6f, 0x55, 0x01, 0x27,
+0x61, 0x6e, 0x1f, 0x01, 0x08, 0x4f, 0x00, 0x06, 0x1f, 0x01, 0x01, 0xa2,
+0x00, 0x00, 0x96, 0x0d, 0x0c, 0x5a, 0x00, 0x28, 0x20, 0x28, 0x31, 0x00,
+0x13, 0x2a, 0xbd, 0x01, 0x49, 0x50, 0x74, 0x72, 0x29, 0x8c, 0x00, 0x00,
+0xde, 0x1d, 0x23, 0x74, 0x65, 0x33, 0x00, 0x01, 0x82, 0x04, 0x05, 0x9e,
+0x0e, 0x00, 0x1d, 0x04, 0x00, 0x87, 0x00, 0x30, 0x69, 0x61, 0x6c, 0x8d,
+0x06, 0x2f, 0x61, 0x6e, 0x83, 0x00, 0x07, 0x01, 0x1a, 0x00, 0x34, 0x66,
+0x72, 0x65, 0x49, 0x00, 0x21, 0x72, 0x65, 0x67, 0x01, 0x11, 0x73, 0x26,
+0x21, 0x02, 0x0f, 0x09, 0x02, 0xb4, 0x21, 0x02, 0x09, 0x06, 0x01, 0x1e,
+0x02, 0x11, 0x78, 0x9d, 0x26, 0x01, 0x97, 0x01, 0x22, 0x20, 0x28, 0xa8,
+0x01, 0x19, 0x29, 0xa0, 0x01, 0x55, 0x74, 0x68, 0x65, 0x73, 0x65, 0x93,
+0x01, 0x44, 0x72, 0x61, 0x74, 0x68, 0x07, 0x09, 0x24, 0x74, 0x68, 0x0c,
+0x02, 0x03, 0x86, 0x00, 0x01, 0x5d, 0x00, 0x41, 0x54, 0x68, 0x65, 0x79,
+0xfb, 0x01, 0x01, 0x51, 0x1b, 0x42, 0x66, 0x75, 0x74, 0x75, 0xa9, 0x04,
+0x20, 0x6f, 0x66, 0x19, 0x04, 0x01, 0x1b, 0x13, 0x02, 0x72, 0x00, 0x02,
+0xf1, 0x20, 0x00, 0x0c, 0x00, 0x0a, 0xd1, 0x00, 0x32, 0x69, 0x7a, 0x65,
+0xf2, 0x01, 0x0a, 0x3a, 0x01, 0x0c, 0x27, 0x01, 0x08, 0x2c, 0x0f, 0x06,
+0x01, 0x00, 0x0b, 0x02, 0x01, 0x0f, 0x7e, 0x01, 0x13, 0x8f, 0x6c, 0x6f,
+0x61, 0x64, 0x44, 0x69, 0x63, 0x74, 0x07, 0x02, 0x06, 0x00, 0x21, 0x00,
+0x24, 0x20, 0x61, 0xed, 0x00, 0x21, 0x64, 0x69, 0x19, 0x00, 0x00, 0x86,
+0x22, 0x01, 0x42, 0x08, 0x06, 0x64, 0x00, 0x01, 0x95, 0x03, 0x11, 0x41,
+0xdf, 0x09, 0x26, 0x65, 0x76, 0x86, 0x05, 0x04, 0xcc, 0x0d, 0x50, 0x66,
+0x6f, 0x72, 0x67, 0x6f, 0x27, 0x0d, 0x12, 0x2c, 0x75, 0x03, 0x16, 0x27,
+0x4a, 0x00, 0x12, 0x27, 0x25, 0x00, 0x30, 0x72, 0x65, 0x6d, 0xe4, 0x28,
+0x28, 0x69, 0x6e, 0xaf, 0x01, 0x32, 0x4c, 0x6f, 0x61, 0x87, 0x06, 0x05,
+0x10, 0x1a, 0x12, 0x30, 0x96, 0x15, 0x31, 0x6c, 0x6f, 0x77, 0xf8, 0x06,
+0x00, 0xea, 0x1f, 0x03, 0x00, 0x08, 0x07, 0x9c, 0x00, 0x13, 0x73, 0x8c,
+0x05, 0x03, 0x2c, 0x07, 0x0c, 0xe4, 0x07, 0x50, 0x36, 0x34, 0x20, 0x4b,
+0x42, 0x5d, 0x20, 0x06, 0x1b, 0x06, 0x04, 0x08, 0x01, 0x0f, 0x37, 0x01,
+0x06, 0x0a, 0x6d, 0x10, 0x06, 0x6c, 0x00, 0x02, 0xf3, 0x05, 0x00, 0x10,
+0x00, 0x07, 0xe0, 0x09, 0x2f, 0x20, 0x2a, 0xc4, 0x10, 0x00, 0x00, 0x74,
+0x02, 0x31, 0x69, 0x6e, 0x75, 0xae, 0x02, 0x04, 0xcd, 0x05, 0x08, 0x65,
+0x24, 0x00, 0xae, 0x04, 0x63, 0x27, 0x73, 0x72, 0x63, 0x27, 0x2c, 0x3b,
+0x04, 0x01, 0x41, 0x01, 0x01, 0x96, 0x0a, 0x04, 0x54, 0x01, 0x2d, 0x6c,
+0x79, 0x4a, 0x08, 0x10, 0x73, 0x5b, 0x04, 0x07, 0xfb, 0x00, 0x25, 0x74,
+0x6f, 0xe3, 0x20, 0x0d, 0x19, 0x21, 0x02, 0x02, 0x03, 0x07, 0x39, 0x05,
+0x19, 0x50, 0xac, 0x01, 0x04, 0x50, 0x00, 0x10, 0x72, 0xdf, 0x13, 0x33,
+0x73, 0x75, 0x6d, 0xc4, 0x1e, 0x13, 0x74, 0xc3, 0x01, 0x00, 0x4c, 0x00,
+0x00, 0xa4, 0x00, 0x01, 0x41, 0x2b, 0x15, 0x6e, 0xa5, 0x0b, 0x01, 0x50,
+0x05, 0x27, 0x27, 0x64, 0x11, 0x10, 0x0f, 0x99, 0x1b, 0x09, 0x01, 0x36,
+0x25, 0x00, 0x21, 0x07, 0x03, 0xc4, 0x0e, 0x0f, 0xbd, 0x16, 0x0a, 0x00,
+0x74, 0x01, 0x0f, 0x5e, 0x1f, 0x0f, 0x02, 0x45, 0x08, 0x07, 0x24, 0x1f,
+0x04, 0x67, 0x00, 0x32, 0x6e, 0x6f, 0x74, 0x1c, 0x00, 0x2d, 0x69, 0x66,
+0x85, 0x25, 0x03, 0x13, 0x1f, 0x25, 0x66, 0x69, 0xfc, 0x10, 0x07, 0xc1,
+0x00, 0x02, 0x3f, 0x02, 0x0d, 0xf6, 0x1e, 0x02, 0x4d, 0x00, 0x07, 0xe4,
+0x1e, 0x00, 0x79, 0x02, 0x00, 0xd8, 0x05, 0x03, 0xe4, 0x1e, 0x07, 0x4f,
+0x02, 0x0f, 0xfa, 0x01, 0x03, 0x0f, 0x5d, 0x02, 0x14, 0x35, 0x73, 0x72,
+0x63, 0x7f, 0x08, 0x05, 0xbe, 0x14, 0x2a, 0x72, 0x63, 0x61, 0x08, 0x0f,
+0xc3, 0x12, 0x09, 0x07, 0x63, 0x07, 0x34, 0x61, 0x76, 0x65, 0xdf, 0x03,
+0x2f, 0x49, 0x66, 0x48, 0x02, 0x04, 0x06, 0xfd, 0x01, 0x04, 0xab, 0x1c,
+0x0a, 0x68, 0x01, 0x03, 0x9a, 0x03, 0x51, 0x61, 0x76, 0x61, 0x69, 0x6c,
+0xd2, 0x26, 0x27, 0x61, 0x74, 0x57, 0x05, 0x14, 0x20, 0xe5, 0x18, 0x00,
+0x64, 0x00, 0x00, 0x70, 0x00, 0x14, 0x20, 0x54, 0x01, 0x20, 0x61, 0x20,
+0x66, 0x09, 0x21, 0x72, 0x20, 0xf0, 0x15, 0x23, 0x20, 0x28, 0xdd, 0x00,
+0x41, 0x61, 0x66, 0x65, 0x42, 0x67, 0x01, 0x01, 0xde, 0x23, 0x03, 0x53,
+0x0b, 0x00, 0x34, 0x07, 0x55, 0x64, 0x6f, 0x6e, 0x27, 0x74, 0x4e, 0x27,
+0x00, 0x65, 0x07, 0x09, 0x9a, 0x03, 0xa0, 0x28, 0x29, 0x20, 0x61, 0x66,
+0x74, 0x65, 0x72, 0x77, 0x61, 0x05, 0x10, 0x07, 0x73, 0x07, 0x08, 0x94,
+0x04, 0x27, 0x73, 0x20, 0x99, 0x20, 0x00, 0xf6, 0x23, 0x63, 0x62, 0x6c,
+0x65, 0x2c, 0x20, 0x79, 0xed, 0x28, 0x06, 0x3e, 0x0a, 0x05, 0x5e, 0x00,
+0x0f, 0xa9, 0x01, 0x03, 0x29, 0x28, 0x29, 0x5a, 0x04, 0x00, 0xd6, 0x00,
+0x1c, 0x64, 0x60, 0x04, 0x0f, 0x5f, 0x04, 0x07, 0x05, 0x0d, 0x04, 0x15,
+0x2c, 0xda, 0x11, 0x01, 0xcd, 0x1d, 0x09, 0x22, 0x02, 0x04, 0x9a, 0x01,
+0x0f, 0x71, 0x04, 0x09, 0x0b, 0x31, 0x01, 0x0e, 0x6b, 0x04, 0x0e, 0x53,
+0x0a, 0x0f, 0x54, 0x0a, 0x1b, 0x06, 0xa7, 0x0a, 0x0f, 0x56, 0x0a, 0x2a,
+0x00, 0x63, 0x1d, 0x0e, 0x1b, 0x0a, 0x65, 0x44, 0x45, 0x43, 0x4f, 0x44,
+0x45, 0x0d, 0x0a, 0x2f, 0x20, 0x34, 0x24, 0x00, 0x0a, 0x0c, 0x45, 0x0a,
+0x0b, 0x3e, 0x00, 0x05, 0x4b, 0x0a, 0x04, 0xe3, 0x1c, 0x18, 0x20, 0x54,
+0x0a, 0x0d, 0x21, 0x09, 0x0e, 0x26, 0x00, 0x0d, 0x2a, 0x09, 0x0a, 0x61,
+0x00, 0x0b, 0x30, 0x09, 0x11, 0x44, 0x59, 0x0d, 0x00, 0x36, 0x09, 0x0c,
+0xaf, 0x0a, 0x04, 0x1a, 0x00, 0x0f, 0xb5, 0x0a, 0x23, 0x0f, 0xa9, 0x0a,
+0x08, 0x23, 0x75, 0x73, 0x4e, 0x0a, 0x15, 0x5f, 0x42, 0x09, 0x02, 0x6c,
+0x00, 0x12, 0x20, 0xde, 0x1c, 0x20, 0x73, 0x65, 0x03, 0x03, 0x0f, 0xcf,
+0x0a, 0x02, 0x0f, 0xd9, 0x08, 0x11, 0x04, 0xd8, 0x08, 0x30, 0x70, 0x72,
+0x65, 0x94, 0x03, 0x02, 0x11, 0x27, 0x2f, 0x6f, 0x66, 0x7e, 0x0a, 0x03,
+0x01, 0x99, 0x0a, 0x0f, 0xd3, 0x08, 0x2f, 0x04, 0x2c, 0x01, 0x05, 0x30,
+0x03, 0x24, 0x74, 0x68, 0x44, 0x00, 0x1f, 0x2e, 0xff, 0x09, 0x01, 0x03,
+0xf0, 0x00, 0x0f, 0x05, 0x0a, 0x17, 0x06, 0x61, 0x00, 0x0f, 0x0b, 0x0a,
+0x07, 0x03, 0x55, 0x00, 0x0f, 0x11, 0x0a, 0x04, 0x2e, 0x2f, 0x0a, 0x4e,
+0x00, 0x0f, 0x99, 0x00, 0x05, 0x0e, 0x77, 0x09, 0x0f, 0x7d, 0x09, 0x05,
+0x03, 0x74, 0x00, 0x1f, 0x28, 0x5c, 0x00, 0x05, 0x02, 0x14, 0x00, 0x0b,
+0xab, 0x05, 0x0a, 0xf6, 0x01, 0x0f, 0x98, 0x0b, 0x08, 0x03, 0xe6, 0x02,
+0x02, 0xfb, 0x16, 0x01, 0xe8, 0x16, 0x03, 0x7f, 0x25, 0x06, 0xa2, 0x04,
+0x01, 0x5f, 0x01, 0x12, 0x53, 0x14, 0x26, 0x0f, 0x3d, 0x09, 0x04, 0x21,
+0x20, 0x28, 0xc9, 0x1b, 0x02, 0xf4, 0x28, 0x02, 0xd0, 0x1b, 0x4a, 0x73,
+0x65, 0x74, 0x29, 0x54, 0x09, 0x10, 0x31, 0xbd, 0x04, 0x3f, 0x4f, 0x4b,
+0x2c, 0xc6, 0x04, 0x06, 0x2f, 0x65, 0x74, 0xf2, 0x00, 0x19, 0x02, 0x14,
+0x00, 0x0f, 0x4b, 0x09, 0x1a, 0x17, 0x2a, 0x95, 0x05, 0x05, 0x1a, 0x13,
+0x00, 0x97, 0x0b, 0x05, 0xa3, 0x10, 0x05, 0xc2, 0x2d, 0x02, 0xda, 0x00,
+0x0b, 0x29, 0x12, 0x80, 0x6f, 0x66, 0x20, 0x6d, 0x75, 0x6c, 0x74, 0x69,
+0x39, 0x29, 0x03, 0xe1, 0x08, 0x54, 0x69, 0x6e, 0x20, 0x22, 0x73, 0x04,
+0x05, 0x10, 0x22, 0x6f, 0x14, 0x03, 0x4b, 0x12, 0x16, 0x50, 0x1f, 0x07,
+0x04, 0x39, 0x12, 0x03, 0x64, 0x09, 0x10, 0x2a, 0xd4, 0x08, 0x1f, 0x2a,
+0x0a, 0x07, 0x02, 0x01, 0x0d, 0x21, 0x02, 0x0a, 0x07, 0x05, 0x6b, 0x13,
+0x03, 0x9b, 0x01, 0x00, 0x3c, 0x03, 0x08, 0xa8, 0x11, 0x40, 0x20, 0x28,
+0x75, 0x70, 0xb1, 0x01, 0x04, 0x80, 0x0a, 0x25, 0x20, 0x20, 0xb7, 0x03,
+0x05, 0x48, 0x03, 0x10, 0x72, 0xd3, 0x00, 0x02, 0x88, 0x08, 0x17, 0x73,
+0x26, 0x24, 0x0b, 0x5b, 0x09, 0x03, 0xde, 0x19, 0x02, 0x10, 0x01, 0x51,
+0x2d, 0x20, 0x45, 0x78, 0x61, 0xb8, 0x0e, 0x01, 0xd2, 0x01, 0x01, 0x3a,
+0x25, 0x59, 0x61, 0x73, 0x20, 0x65, 0x6e, 0x3c, 0x00, 0x03, 0x1d, 0x1e,
+0x01, 0x23, 0x00, 0x30, 0x75, 0x70, 0x64, 0x5b, 0x03, 0x62, 0x72, 0x75,
+0x6c, 0x65, 0x20, 0x28, 0xfa, 0x07, 0x07, 0x2c, 0x16, 0x22, 0x61, 0x74,
+0x26, 0x00, 0x04, 0xcf, 0x00, 0x14, 0x73, 0x01, 0x13, 0x23, 0x49, 0x6e,
+0x90, 0x1d, 0x00, 0xaf, 0x00, 0x02, 0x3c, 0x12, 0x05, 0x86, 0x01, 0x16,
+0x26, 0x70, 0x00, 0x07, 0xc3, 0x00, 0x01, 0x77, 0x07, 0x32, 0x68, 0x61,
+0x76, 0xfa, 0x15, 0x04, 0x97, 0x0b, 0x04, 0x07, 0x24, 0x42, 0x76, 0x65,
+0x72, 0x79, 0xfd, 0x12, 0x30, 0x20, 0x6f, 0x6e, 0x49, 0x07, 0x23, 0x20,
+0x3c, 0x1c, 0x01, 0x13, 0x2e, 0xd9, 0x00, 0x14, 0x4c, 0x5a, 0x1f, 0x2e,
+0x61, 0x6e, 0xd0, 0x00, 0x2a, 0x62, 0x79, 0x33, 0x17, 0x40, 0x6d, 0x61,
+0x78, 0x42, 0xcc, 0x00, 0x01, 0x59, 0x0a, 0x01, 0xb0, 0x04, 0x07, 0x36,
+0x17, 0x1a, 0x20, 0x1f, 0x00, 0x01, 0x2a, 0x08, 0x36, 0x70, 0x6c, 0x65,
+0x65, 0x34, 0x30, 0x64, 0x65, 0x70, 0x4b, 0x29, 0x32, 0x6e, 0x74, 0x2e,
+0x6e, 0x1f, 0x0d, 0xe5, 0x22, 0x00, 0x46, 0x08, 0x01, 0xa9, 0x16, 0x18,
+0x64, 0xdc, 0x1c, 0x05, 0xeb, 0x08, 0x34, 0x69, 0x6e, 0x67, 0x63, 0x02,
+0x1f, 0x2e, 0x30, 0x01, 0x03, 0x27, 0x65, 0x6e, 0x55, 0x13, 0x0b, 0xda,
+0x01, 0x41, 0x73, 0x20, 0x64, 0x6f, 0x7b, 0x09, 0x04, 0x00, 0x09, 0x00,
+0x17, 0x14, 0x94, 0x79, 0x6e, 0x63, 0x68, 0x72, 0x6f, 0x6e, 0x69, 0x7a,
+0x0d, 0x15, 0x02, 0xbe, 0x1d, 0x0f, 0x69, 0x01, 0x1f, 0x0f, 0x64, 0x01,
+0x0a, 0x40, 0x5f, 0x41, 0x74, 0x20, 0x1c, 0x05, 0x22, 0x74, 0x5f, 0x19,
+0x00, 0x43, 0x20, 0x2b, 0x20, 0x38, 0xda, 0x08, 0x19, 0x2b, 0x35, 0x01,
+0x0f, 0xd7, 0x00, 0x7e, 0x17, 0x6c, 0x1e, 0x02, 0x0b, 0x79, 0x00, 0x02,
+0xac, 0x00, 0x32, 0x57, 0x68, 0x65, 0x5d, 0x14, 0x02, 0xca, 0x0f, 0x0a,
+0x8c, 0x37, 0x02, 0x99, 0x18, 0x03, 0x9d, 0x1c, 0x12, 0x2c, 0xbb, 0x0a,
+0x01, 0xd3, 0x1d, 0x00, 0xda, 0x17, 0x00, 0x90, 0x2e, 0x02, 0x7f, 0x28,
+0x02, 0xba, 0x03, 0x01, 0x24, 0x0b, 0x07, 0xd6, 0x0a, 0x04, 0x85, 0x02,
+0x05, 0x53, 0x1f, 0x05, 0xa1, 0x1c, 0x02, 0xfc, 0x03, 0x11, 0x69, 0xaf,
+0x14, 0x02, 0x39, 0x0a, 0x0f, 0xda, 0x07, 0x06, 0x2f, 0x28, 0x29, 0x9e,
+0x14, 0x09, 0x0e, 0x36, 0x0c, 0x0f, 0x55, 0x05, 0x0b, 0x0f, 0x70, 0x2d,
+0x3b, 0x0f, 0xf3, 0x18, 0x04, 0x0f, 0x96, 0x00, 0x42, 0x0c, 0x22, 0x19,
+0x00, 0xf8, 0x05, 0x05, 0x87, 0x27, 0x0f, 0xe8, 0x05, 0x00, 0x41, 0x3a,
+0x0a, 0x2a, 0x5f, 0x55, 0x01, 0x03, 0x18, 0x0c, 0x0f, 0x17, 0x06, 0x0c,
+0x48, 0x77, 0x6f, 0x72, 0x6b, 0xba, 0x22, 0x02, 0xb4, 0x01, 0x00, 0x0c,
+0x01, 0x14, 0x62, 0x0d, 0x18, 0x2f, 0x6f, 0x66, 0xa0, 0x01, 0x03, 0x03,
+0xa8, 0x38, 0x02, 0xae, 0x22, 0x0b, 0x0f, 0x01, 0x19, 0x78, 0x2f, 0x0c,
+0x26, 0x20, 0x20, 0x2c, 0x09, 0xc2, 0x73, 0x74, 0x61, 0x6e, 0x64, 0x2d,
+0x61, 0x6c, 0x6f, 0x6e, 0x65, 0x2e, 0x16, 0x00, 0x07, 0xdc, 0x0c, 0x00,
+0xb0, 0x28, 0x03, 0x80, 0x05, 0x0f, 0xcc, 0x08, 0x0c, 0x1f, 0x2e, 0x1e,
+0x02, 0x09, 0x05, 0x00, 0x01, 0x0f, 0x69, 0x2f, 0x3a, 0x0e, 0x9b, 0x07,
+0x5d, 0x53, 0x74, 0x61, 0x72, 0x74, 0x9a, 0x07, 0x0f, 0x1e, 0x02, 0x05,
+0x0e, 0x96, 0x00, 0x0f, 0x1b, 0x1b, 0x12, 0x0f, 0x7b, 0x00, 0x19, 0x0f,
+0xce, 0x29, 0x1b, 0x40, 0x4f, 0x62, 0x73, 0x6f, 0x9d, 0x20, 0x0f, 0xce,
+0x29, 0x20, 0x10, 0x2f, 0x07, 0x32, 0x00, 0xd3, 0x2c, 0x00, 0xab, 0x01,
+0x30, 0x57, 0x61, 0x72, 0x43, 0x33, 0x22, 0x73, 0x20, 0x19, 0x00, 0x15,
+0x53, 0xdb, 0x19, 0x44, 0x73, 0x65, 0x20, 0x77, 0x1c, 0x00, 0x10, 0x6d,
+0x06, 0x0e, 0x00, 0xc9, 0x34, 0x01, 0xcd, 0x1d, 0x71, 0x70, 0x72, 0x6f,
+0x62, 0x6c, 0x65, 0x6d, 0x23, 0x04, 0x02, 0x0f, 0x04, 0x02, 0x22, 0x36,
+0x00, 0x3d, 0x16, 0x05, 0x14, 0x21, 0x00, 0x08, 0x1a, 0x11, 0x69, 0xa7,
+0x0e, 0x00, 0x4d, 0x00, 0x02, 0x2d, 0x00, 0x01, 0xa8, 0x07, 0x64, 0x2d,
+0x57, 0x6e, 0x6f, 0x2d, 0x64, 0x80, 0x00, 0x72, 0x64, 0x2d, 0x64, 0x65,
+0x63, 0x6c, 0x61, 0xe3, 0x0f, 0x02, 0xce, 0x1d, 0x42, 0x67, 0x63, 0x63,
+0x0a, 0x3c, 0x20, 0x70, 0x5f, 0x43, 0x52, 0x54, 0x5f, 0x53, 0x45, 0x2f,
+0x39, 0xc0, 0x5f, 0x4e, 0x4f, 0x5f, 0x57, 0x41, 0x52, 0x4e, 0x49, 0x4e,
+0x47, 0x53, 0xe8, 0x08, 0x68, 0x56, 0x69, 0x73, 0x75, 0x61, 0x6c, 0x7f,
+0x28, 0x18, 0x2e, 0xfe, 0x37, 0x01, 0x7c, 0x26, 0x07, 0x95, 0x0d, 0x94,
+0x44, 0x45, 0x50, 0x52, 0x45, 0x43, 0x41, 0x54, 0x45, 0x45, 0x00, 0x00,
+0x95, 0x25, 0x61, 0x42, 0x4c, 0x4f, 0x43, 0x4b, 0x2e, 0x97, 0x2a, 0x30,
+0x69, 0x66, 0x6e, 0x67, 0x0d, 0x0f, 0x2b, 0x00, 0x0b, 0x3e, 0x0a, 0x23,
+0x20, 0x54, 0x00, 0x0f, 0x29, 0x00, 0x10, 0x34, 0x47, 0x43, 0x43, 0x04,
+0x35, 0x00, 0xe0, 0x37, 0x92, 0x47, 0x4e, 0x55, 0x43, 0x5f, 0x5f, 0x20,
+0x2a, 0x20, 0x22, 0x35, 0x03, 0x11, 0x00, 0x01, 0x36, 0x35, 0x30, 0x5f,
+0x5f, 0x29, 0x3c, 0x00, 0x4c, 0x69, 0x66, 0x20, 0x28, 0x39, 0x00, 0xa4,
+0x3e, 0x3d, 0x20, 0x34, 0x30, 0x35, 0x29, 0x20, 0x7c, 0x7c, 0x2c, 0x38,
+0x00, 0x2b, 0x38, 0x43, 0x6c, 0x61, 0x6e, 0x67, 0x35, 0x00, 0x0f, 0x9c,
+0x00, 0x03, 0x23, 0x44, 0x28, 0xbc, 0x01, 0x62, 0x29, 0x20, 0x5f, 0x5f,
+0x61, 0x74, 0x42, 0x3c, 0x56, 0x65, 0x5f, 0x5f, 0x28, 0x28, 0x83, 0x01,
+0x05, 0x23, 0x00, 0x11, 0x29, 0x49, 0x00, 0x2f, 0x65, 0x6c, 0x80, 0x00,
+0x04, 0x3f, 0x33, 0x30, 0x31, 0x6a, 0x00, 0x2c, 0x07, 0x61, 0x00, 0x05,
+0xc5, 0x00, 0x21, 0x4d, 0x53, 0x65, 0x00, 0x0f, 0x5a, 0x00, 0x15, 0x00,
+0x2f, 0x02, 0x00, 0x0c, 0x20, 0x0f, 0xc0, 0x00, 0x02, 0x02, 0x5e, 0x00,
+0x22, 0x73, 0x65, 0x4c, 0x00, 0x03, 0x65, 0x39, 0x03, 0x1e, 0x00, 0x23,
+0x28, 0x22, 0xa7, 0x01, 0x37, 0x3a, 0x20, 0x59, 0xdd, 0x38, 0x05, 0x2d,
+0x09, 0x0b, 0x74, 0x00, 0x02, 0x35, 0x37, 0x00, 0xa4, 0x0c, 0x02, 0x18,
+0x2b, 0x3f, 0x65, 0x72, 0x22, 0xa3, 0x00, 0x12, 0x01, 0x83, 0x00, 0x01,
+0xa9, 0x39, 0x02, 0xb0, 0x39, 0x00, 0x0d, 0x2d, 0x0f, 0x2e, 0x02, 0x0b,
+0x12, 0x20, 0xc1, 0x38, 0x06, 0xd2, 0x03, 0x0f, 0xc6, 0x39, 0x02, 0x03,
+0xa0, 0x03, 0x02, 0x0c, 0x06, 0x07, 0x1a, 0x0c, 0x00, 0xb6, 0x0e, 0x44,
+0x6c, 0x61, 0x6e, 0x6e, 0xd4, 0x14, 0x36, 0x61, 0x72, 0x74, 0xb1, 0x39,
+0x05, 0xc1, 0x03, 0xf2, 0x01, 0x62, 0x79, 0x20, 0x72, 0x31, 0x33, 0x31,
+0x20, 0x61, 0x70, 0x70, 0x72, 0x6f, 0x78, 0x69, 0x6d, 0x47, 0x12, 0x0f,
+0xd8, 0x13, 0x00, 0x0b, 0xfe, 0x0d, 0x0f, 0x81, 0x28, 0x1c, 0x0f, 0xe7,
+0x26, 0x01, 0x03, 0x7f, 0x33, 0x02, 0x4c, 0x1c, 0x0f, 0xd2, 0x28, 0x26,
+0x07, 0xeb, 0x31, 0x0f, 0x64, 0x00, 0x00, 0x00, 0x59, 0x04, 0x02, 0x47,
+0x27, 0x0b, 0xbf, 0x00, 0x0f, 0x55, 0x27, 0x27, 0x0f, 0xcb, 0x00, 0x0e,
+0x07, 0x75, 0x00, 0x0f, 0xbc, 0x27, 0x31, 0x0f, 0xe1, 0x00, 0x0b, 0x05,
+0x9d, 0x08, 0x0c, 0xe1, 0x00, 0x0e, 0x50, 0x19, 0x0e, 0x7c, 0x15, 0x0f,
+0xf1, 0x00, 0x35, 0x06, 0x85, 0x00, 0x0f, 0x77, 0x00, 0x38, 0x0f, 0x01,
+0x01, 0x03, 0x09, 0x10, 0x03, 0x2f, 0x64, 0x65, 0x12, 0x03, 0x17, 0x30,
+0x20, 0x6e, 0x61, 0xf3, 0x22, 0x13, 0x61, 0x6c, 0x2a, 0x03, 0xbf, 0x27,
+0x06, 0x2c, 0x04, 0x01, 0xd3, 0x0a, 0x01, 0x6d, 0x0e, 0x21, 0x6e, 0x6f,
+0x3f, 0x13, 0x41, 0x65, 0x72, 0x20, 0x62, 0x15, 0x1b, 0x02, 0x6d, 0x20,
+0x05, 0xeb, 0x08, 0x01, 0xcd, 0x19, 0x05, 0x20, 0x2f, 0x01, 0xfb, 0x0a,
+0x04, 0x25, 0x2f, 0x31, 0x61, 0x74, 0x69, 0x83, 0x3b, 0x03, 0x17, 0x28,
+0x20, 0x6f, 0x6c, 0x0d, 0x44, 0x03, 0x43, 0x3d, 0x15, 0x73, 0xe1, 0x0d,
+0x36, 0x5a, 0x34, 0x5f, 0x30, 0x26, 0x0c, 0x63, 0x2c, 0x0f, 0x63, 0x08,
+0x00, 0x0f, 0x38, 0x00, 0x02, 0x30, 0x5f, 0x75, 0x6e, 0x03, 0x2b, 0x16,
+0x6e, 0x1d, 0x01, 0x0f, 0x4a, 0x00, 0x0c, 0x00, 0x43, 0x09, 0x03, 0xc8,
+0x00, 0x08, 0x16, 0x01, 0x00, 0x55, 0x20, 0x10, 0x6f, 0x4d, 0x14, 0x04,
+0x21, 0x0c, 0x14, 0x77, 0x9e, 0x07, 0x22, 0x64, 0x3b, 0xd7, 0x26, 0x01,
+0x03, 0x05, 0x00, 0xaa, 0x07, 0x02, 0xfa, 0x00, 0x03, 0x1b, 0x1e, 0x21,
+0x72, 0x65, 0xd6, 0x07, 0x02, 0x2d, 0x05, 0x20, 0x68, 0x65, 0xed, 0x13,
+0x04, 0x43, 0x25, 0x21, 0x68, 0x69, 0x6c, 0x2d, 0x08, 0xac, 0x37, 0x04,
+0x27, 0x23, 0x02, 0x18, 0x0c, 0x02, 0x44, 0x08, 0x08, 0x7a, 0x00, 0x00,
+0x7b, 0x01, 0x21, 0x69, 0x67, 0x9a, 0x04, 0x30, 0x74, 0x6f, 0x20, 0x72,
+0x10, 0x21, 0x74, 0x61, 0xf6, 0x3e, 0x01, 0xc1, 0x0d, 0x02, 0xcf, 0x01,
+0x04, 0x84, 0x02, 0x07, 0x3c, 0x01, 0x0f, 0x72, 0x09, 0x13, 0x07, 0x3f,
+0x02, 0x0e, 0x4b, 0x00, 0x0f, 0x4f, 0x01, 0x01, 0x0f, 0x6c, 0x28, 0x17,
+0x3f, 0x20, 0x69, 0x73, 0xaa, 0x02, 0x05, 0x0d, 0xbd, 0x05, 0x05, 0x80,
+0x11, 0x06, 0xa8, 0x0b, 0x11, 0x3b, 0xd0, 0x14, 0x00, 0xd7, 0x3d, 0x06,
+0x1d, 0x00, 0x06, 0x24, 0x3e, 0x14, 0x77, 0xcb, 0x0d, 0x05, 0x3b, 0x09,
+0x03, 0xbc, 0x13, 0x07, 0x5d, 0x06, 0x11, 0x22, 0x30, 0x46, 0x0c, 0x2d,
+0x1d, 0x14, 0x29, 0x4d, 0x1f, 0x32, 0x22, 0x29, 0x20, 0x82, 0x04, 0x06,
+0xdf, 0x13, 0x04, 0x96, 0x18, 0x01, 0x68, 0x03, 0x03, 0x97, 0x18, 0x1f,
+0x3b, 0x57, 0x00, 0x1f, 0x02, 0x12, 0x14, 0x08, 0xd2, 0x2c, 0x00, 0x23,
+0x00, 0x09, 0xd8, 0x2c, 0x0f, 0x54, 0x00, 0x05, 0x07, 0x31, 0x1f, 0x09,
+0x53, 0x00, 0x07, 0x54, 0x00, 0x07, 0x23, 0x00, 0x06, 0x53, 0x00, 0x06,
+0x48, 0x05, 0x0f, 0xc1, 0x00, 0x18, 0x04, 0x75, 0x18, 0x0a, 0x6a, 0x00,
+0x23, 0x20, 0x20, 0x45, 0x00, 0x01, 0x23, 0x00, 0x56, 0x6c, 0x69, 0x64,
+0x65, 0x49, 0x4e, 0x00, 0x09, 0xb6, 0x05, 0x2f, 0x29, 0x3b, 0xc6, 0x01,
+0x05, 0x0f, 0x77, 0x0d, 0x00, 0x0f, 0xa0, 0x01, 0x03, 0x0f, 0xcd, 0x0c,
+0x0b, 0x0d, 0x56, 0x01, 0x0f, 0xfb, 0x0c, 0x01, 0x00, 0x4f, 0x04, 0xbf,
+0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x36, 0x34, 0x6b, 0x20, 0x28, 0x3b,
+0x1b, 0x0d, 0x0f, 0xfb, 0x0c, 0x05, 0x05, 0xfe, 0x2a, 0x0f, 0xa6, 0x00,
+0x10, 0x0a, 0xdd, 0x0c, 0x0f, 0xa6, 0x00, 0x0d, 0x01, 0x2e, 0x00, 0x0f,
+0xa6, 0x00, 0x1c, 0x0d, 0x04, 0x0f, 0x0f, 0xef, 0x42, 0x07, 0x90, 0x7d,
+0x0a, 0x23, 0x65, 0x6e, 0x64, 0x69, 0x66, 0x0a,
+};
+
+static unsigned char buf[18830];
+
+int main() {
+
+       unsigned long cksum = adler32(0, NULL, 0);
+
+       decompress_lz4(compressed, buf, 18830);
+       cksum = adler32(cksum, buf, 18830);
+
+       return cksum == 0xf748269d ? 0 : 1;
+}
diff --git a/test/val/postincdec.c b/test/val/postincdec.c
new file mode 100644 (file)
index 0000000..6d3e959
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+  !!DESCRIPTION!! char-sized post-increment and -decrement
+  !!ORIGIN!!      cc65 regression tests
+  !!LICENCE!!     Public Domain
+  !!AUTHOR!!      Lauri Kasanen
+*/
+
+
+static unsigned char val, array[2];
+
+int main() {
+
+       val = 0;
+       array[0] = array[1] = 10;
+
+       array[val++] = 2;
+       array[val++] = 2;
+       --val;
+       array[val--] = 0;
+       array[val--] = 0;
+
+       return (array[0] == array[1] && array[0] == 0 && val == 0xff) ? 0 : 1;
+}
diff --git a/test/val/static-fwd-decl.c b/test/val/static-fwd-decl.c
new file mode 100644 (file)
index 0000000..420640d
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+  !!DESCRIPTION!! static forward declarations
+  !!ORIGIN!!      cc65 regression tests
+  !!LICENCE!!     Public Domain
+  !!AUTHOR!!      Bob Andrews
+*/
+
+/*
+  see: https://github.com/cc65/cc65/issues/204
+*/
+
+#pragma warn(error, on)
+
+typedef struct _DIRMENU
+{
+    const char *name;
+    struct _DIRMENU *dest;
+} DIRMENU; 
+
+static DIRMENU rmenu;
+
+static DIRMENU lmenu = {
+    "left",
+    &rmenu
+};
+
+static DIRMENU rmenu = {
+    "right",
+    &lmenu
+};
+
+int main(void)
+{
+    return lmenu.dest == &rmenu && rmenu.dest == &lmenu ? 0 : 1;
+}
diff --git a/test/val/strtol-test.c b/test/val/strtol-test.c
deleted file mode 100644 (file)
index 76daef7..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
-  !!DESCRIPTION!! A small test for atoi/strtol. Assumes twos complement
-  !!ORIGIN!!
-  !!LICENCE!!
-  !!AUTHOR!!
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include <errno.h>
-
-#define ERROR   0
-#define OK      1
-
-static unsigned int Failures = 0;
-
-static void IncStr (char* Buf)
-/* Increment a number represented as a string by one. The string MUST not
- * start with a '9', we cannot handle overflow in this case.
- */
-{
-    int Len = strlen (Buf);
-
-    while (--Len >= 0) {
-        switch (Buf[Len]) {
-            case '9':
-                Buf[Len] = '0';
-                break;
-
-            default:
-                ++(Buf[Len]);
-                return;
-        }
-    }
-}
-
-static void CheckStrToL (const char* Str, int Base, long Val, unsigned char Ok)
-{
-    char* EndPtr;
-    long Res = strtol (Str, &EndPtr, Base);
-    if (Ok) {
-        if (Res != Val) {
-            printf ("strtol error in \"%s\":\n"
-                    "  result = %ld, should be %ld, chars = %d\n",
-                    Str, Res, Val, EndPtr - Str);
-            ++Failures;
-        }
-    } else {
-        if (errno != ERANGE) {
-            printf ("strtol error in \"%s\":\n"
-                    "  should not convert, but errno = %d\n",
-                    Str, errno);
-            ++Failures;
-        }
-        if (Res != Val) {
-            printf ("strtol error in \"%s\":\n"
-                    "  result = %ld, should be %ld, chars = %d\n",
-                    Str, Res, Val, EndPtr - Str);
-            ++Failures;
-        }
-    }
-}
-
-int main (void)
-{
-    char Buf[80];
-
-    /* Prefixed allowed if base = 0 */
-    CheckStrToL ("\t 0x10G ", 0, 16L, OK);
-    CheckStrToL ("\t 0X10G ", 0, 16L, OK);
-    CheckStrToL (" \t0377\t", 0, 255L, OK);
-    CheckStrToL (" 377", 0, 377L, OK);
-
-    CheckStrToL ("\t -0x10G ", 0, -16L, OK);
-    CheckStrToL ("\t -0X10G ", 0, -16L, OK);
-    CheckStrToL (" \t-0377\t", 0, -255L, OK);
-    CheckStrToL (" -377", 0, -377L, OK);
-
-    /* No prefixes if base = 10 */
-    CheckStrToL ("\t 1234 ", 10, 1234L, OK);
-    CheckStrToL ("\t -1234 ", 10, -1234L, OK);
-    CheckStrToL ("\t -0x10G ", 10, 0L, OK);
-    CheckStrToL ("\t -0X10G ", 10, 0L, OK);
-    CheckStrToL (" \t-0377\t", 10, -377L, OK);
-    CheckStrToL (" 0377", 10, 377L, OK);
-
-    /* 0x prefix is allowed if base = 16 */
-    CheckStrToL ("\t 0x1234 ", 16, 0x1234L, OK);
-    CheckStrToL ("\t -0x1234 ", 16, -0x1234L, OK);
-    CheckStrToL ("\t -010G ", 16, -16L, OK);
-    CheckStrToL ("\t 10G ", 16, 16L, OK);
-
-    /* Check LONG_MIN and LONG_MAX */
-    sprintf (Buf, "%ld", LONG_MIN);
-    CheckStrToL (Buf, 0, LONG_MIN, OK);
-    sprintf (Buf, "%ld", LONG_MAX);
-    CheckStrToL (Buf, 0, LONG_MAX, OK);
-
-    /* Check value one smaller */
-    sprintf (Buf+1, "%ld", LONG_MIN);
-    Buf[1] = '0';       /* Overwrite '-' */
-    IncStr (Buf+1);
-    if (Buf[1] == '0') {
-        Buf[1] = '-';
-        Buf[0] = ' ';
-    } else {
-        Buf[0] = '-';
-    }
-    CheckStrToL (Buf, 0, LONG_MIN, ERROR);
-
-    /* Check value one larger */
-    sprintf (Buf+1, "%ld", LONG_MAX);
-    Buf[0] = '0';
-    IncStr (Buf);
-    if (Buf[0] == '0') {
-        Buf[0] = ' ';
-    }
-    CheckStrToL (Buf, 0, LONG_MAX, ERROR);
-
-    /* Check numbers that are much too large or small */
-    CheckStrToL ("-999999999999999999999999999999999999999999999999999999999", 0, LONG_MIN, ERROR);
-    CheckStrToL ("+999999999999999999999999999999999999999999999999999999999", 0, LONG_MAX, ERROR);
-    CheckStrToL (" 999999999999999999999999999999999999999999999999999999999", 0, LONG_MAX, ERROR);
-
-    /* Check a few other bases */
-    CheckStrToL ("aBcD", 36, 481261L, OK);
-    CheckStrToL ("zyaB", 35, 0L, ERROR);
-    CheckStrToL ("zyaB", 36, 1677395L, ERROR);
-
-    printf ("Failures: %u\n", Failures);
-
-    return Failures;
-}
diff --git a/test/val/strtoul-test.c b/test/val/strtoul-test.c
deleted file mode 100644 (file)
index 803fd45..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
-  !!DESCRIPTION!! A small test for strtuol. Assumes twos complement
-  !!ORIGIN!!
-  !!LICENCE!!
-  !!AUTHOR!!
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include <errno.h>
-
-#define ERROR   0
-#define OK      1
-
-static unsigned int Failures = 0;
-
-static void IncStr (char* Buf)
-/* Increment a number represented as a string by one. The string MUST not
- * start with a '9', we cannot handle overflow in this case.
- */
-{
-    int Len = strlen (Buf);
-
-    while (--Len >= 0) {
-        switch (Buf[Len]) {
-            case '9':
-                Buf[Len] = '0';
-                break;
-
-            default:
-                ++(Buf[Len]);
-                return;
-        }
-    }
-}
-
-static void CheckStrToUL (const char* Str, int Base, unsigned long Val, unsigned char Ok)
-{
-    char* EndPtr;
-    unsigned long Res = strtoul (Str, &EndPtr, Base);
-    if (Ok) {
-        if (Res != Val) {
-            printf ("strtol error in \"%s\":\n"
-                    "  result = %lu, should be %lu, chars = %d\n",
-                    Str, Res, Val, EndPtr - Str);
-            ++Failures;
-        }
-    } else {
-        if (errno != ERANGE) {
-            printf ("strtol error in \"%s\":\n"
-                    "  should not convert, but errno = %d\n",
-                    Str, errno);
-            ++Failures;
-        }
-        if (Res != Val) {
-            printf ("strtol error in \"%s\":\n"
-                    "  result = %lu, should be %lu, chars = %d\n",
-                    Str, Res, Val, EndPtr - Str);
-            ++Failures;
-        }
-    }
-}
-
-int main (void)
-{
-    char Buf[80];
-
-    /* Prefixed allowed if base = 0 */
-    CheckStrToUL ("\t 0x10G ", 0, 16UL, OK);
-    CheckStrToUL ("\t 0X10G ", 0, 16UL, OK);
-    CheckStrToUL (" \t0377\t", 0, 255UL, OK);
-    CheckStrToUL (" 377", 0, 377UL, OK);
-
-    CheckStrToUL ("\t -0x10G ", 0, (unsigned long) -16L, OK);
-    CheckStrToUL ("\t -0X10G ", 0, (unsigned long) -16L, OK);
-    CheckStrToUL (" \t-0377\t", 0, (unsigned long) -255L, OK);
-    CheckStrToUL (" -377", 0, (unsigned long) -377L, OK);
-
-    /* No prefixes if base = 10 */
-    CheckStrToUL ("\t 1234 ", 10, 1234UL, OK);
-    CheckStrToUL ("\t -1234 ", 10, (unsigned long) -1234L, OK);
-    CheckStrToUL ("\t -0x10G ", 10, 0UL, OK);
-    CheckStrToUL ("\t -0X10G ", 10, 0UL, OK);
-    CheckStrToUL (" \t-0377\t", 10, (unsigned long) -377L, OK);
-    CheckStrToUL (" 0377", 10, 377UL, OK);
-
-    /* 0x prefix is allowed if base = 16 */
-    CheckStrToUL ("\t 0x1234 ", 16, 0x1234UL, OK);
-    CheckStrToUL ("\t -0x1234 ", 16, (unsigned long) -0x1234L, OK);
-    CheckStrToUL ("\t -010G ", 16, (unsigned long) -16L, OK);
-    CheckStrToUL ("\t 10G ", 16, 16UL, OK);
-
-    /* Check ULONG_MAX */
-    sprintf (Buf, "%lu", ULONG_MAX);
-    CheckStrToUL (Buf, 0, ULONG_MAX, OK);
-
-    /* Check value one larger */
-    sprintf (Buf+1, "%lu", ULONG_MAX);
-    Buf[0] = '0';
-    IncStr (Buf);
-    if (Buf[0] == '0') {
-        Buf[0] = ' ';
-    }
-    CheckStrToUL (Buf, 0, ULONG_MAX, ERROR);
-
-    /* Check numbers that are much too large or small */
-    CheckStrToUL ("-999999999999999999999999999999999999999999999999999999999", 0, ULONG_MAX, ERROR);
-    CheckStrToUL ("+999999999999999999999999999999999999999999999999999999999", 0, ULONG_MAX, ERROR);
-    CheckStrToUL (" 999999999999999999999999999999999999999999999999999999999", 0, ULONG_MAX, ERROR);
-
-    /* Check a few other bases */
-    CheckStrToUL ("aBcD", 36, 481261UL, OK);
-    CheckStrToUL ("zyaB", 35, 0UL, ERROR);
-    CheckStrToUL ("zyaB", 36, 1677395UL, ERROR);
-
-    printf ("Failures: %u\n", Failures);
-
-    return Failures;
-}
diff --git a/test/val/trampoline-params.c b/test/val/trampoline-params.c
new file mode 100644 (file)
index 0000000..890e43e
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+  !!DESCRIPTION!! wrapped-call pragma w/ many params
+  !!ORIGIN!!      cc65 regression tests
+  !!LICENCE!!     Public Domain
+  !!AUTHOR!!      Lauri Kasanen
+*/
+
+#include <stdarg.h>
+
+static unsigned char flag;
+
+static void trampoline_set() {
+       asm("ldy tmp4");
+       asm("sty %v", flag);
+       asm("jsr callptr4");
+}
+
+#pragma wrapped-call(push, trampoline_set, 4)
+long adder(long in);
+#pragma wrapped-call(pop)
+
+long adder(long in) {
+
+       return in + 7;
+}
+
+int main() {
+
+       flag = 0;
+
+       return adder(70436) == 70436 + 7 && flag == 4 ? 0 : 1;
+}
diff --git a/test/val/trampoline-varargs.c b/test/val/trampoline-varargs.c
new file mode 100644 (file)
index 0000000..d154a3d
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+  !!DESCRIPTION!! wrapped-call pragma w/ variadic function
+  !!ORIGIN!!      cc65 regression tests
+  !!LICENCE!!     Public Domain
+  !!AUTHOR!!      Lauri Kasanen
+*/
+
+#include <stdarg.h>
+
+static unsigned char flag;
+
+static void trampoline_set() {
+       // The Y register is used for variadics - save and restore
+       asm("sty tmp3");
+
+       asm("ldy tmp4");
+       asm("sty %v", flag);
+
+       asm("ldy tmp3");
+       asm("jsr callptr4");
+}
+
+#pragma wrapped-call(push, trampoline_set, 4)
+unsigned adder(unsigned char num, ...);
+#pragma wrapped-call(pop)
+
+unsigned adder(unsigned char num, ...) {
+
+       unsigned char i;
+       unsigned sum = 0;
+       va_list ap;
+       va_start(ap, num);
+
+       for (i = 0; i < num; i++) {
+               sum += va_arg(ap, unsigned);
+       }
+
+       va_end(ap);
+
+       return sum;
+}
+
+int main() {
+
+       flag = 0;
+
+       return adder(3, 0, 5, 500) == 505 && flag == 4 ? 0 : 1;
+}
diff --git a/test/val/trampoline.c b/test/val/trampoline.c
new file mode 100644 (file)
index 0000000..63741b5
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+  !!DESCRIPTION!! wrapped-call pragma used for trampolines
+  !!ORIGIN!!      cc65 regression tests
+  !!LICENCE!!     Public Domain
+  !!AUTHOR!!      Lauri Kasanen
+*/
+
+static unsigned char flag;
+
+static void trampoline_set() {
+       asm("ldy tmp4");
+       asm("sty %v", flag);
+       asm("jsr callptr4");
+}
+
+void trampoline_inc() {
+       asm("inc %v", flag);
+       asm("jsr callptr4");
+}
+
+void func3() {
+
+}
+
+#pragma wrapped-call(push, trampoline_inc, 0)
+
+void func2() {
+       func3();
+}
+
+#pragma wrapped-call(push, trampoline_set, 4)
+
+void func1(void);
+
+#pragma wrapped-call(pop)
+#pragma wrapped-call(pop)
+
+void func1() {
+       func2();
+}
+
+int main(void)
+{
+       flag = 0;
+
+       func1();
+
+       return flag == 5 ? 0 : 1;
+}
diff --git a/test/val/unittest.h b/test/val/unittest.h
new file mode 100644 (file)
index 0000000..bd355bb
--- /dev/null
@@ -0,0 +1,89 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                               unittest.h                                  */
+/*                                                                           */
+/*                        Unit test helper macros                            */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2017 Christian Krueger                                                */
+/*                                                                           */
+/* 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 _UNITTEST_H
+#define _UNITTEST_H
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifndef COMMA
+#define COMMA ,
+#endif
+
+#define TEST    int main(void) \
+                {\
+                    printf("%s: ",__FILE__);
+
+#define ENDTEST     printf("Passed\n"); \
+                    return EXIT_SUCCESS; \
+                }
+
+#define ASSERT_IsTrue(a,b)                  if (!(a)) \
+                                            {\
+                                                printf("Fail at line %d:\n",__LINE__);\
+                                                printf(b);\
+                                                printf("\n");\
+                                                printf("Expected status should be true but wasn't!\n");\
+                                                exit(EXIT_FAILURE);\
+                                            }
+
+#define ASSERT_IsFalse(a,b)                 if ((a)) \
+                                            {\
+                                                printf("Fail at line %d:\n",__LINE__);\
+                                                printf(b);\
+                                                printf("\n");\
+                                                printf("Expected status should be false but wasn't!\n");\
+                                                exit(EXIT_FAILURE);\
+                                            }
+
+#define ASSERT_AreEqual(a,b,c,d)            if ((a) != (b)) \
+                                            {\
+                                                printf("Fail at line %d:\n",__LINE__);\
+                                                printf(d);\
+                                                printf("\n");\
+                                                printf("Expected value: "c", but is "c"!\n", (a), (b));\
+                                                exit(EXIT_FAILURE);\
+                                            }
+
+#define ASSERT_AreNotEqual(a,b,c,d)         if ((a) == (b)) \
+                                            {\
+                                                printf("Fail at line %d:\n",__LINE__);\
+                                                printf(d);\
+                                                printf("\n");\
+                                                printf("Expected value not: "c", but is "c"!\n", (a), (b));\
+                                                exit(EXIT_FAILURE);\
+                                            }
+
+/* End of unittest.h */
+#endif
+
+
+
+
diff --git a/test/val/void-size1.c b/test/val/void-size1.c
new file mode 100644 (file)
index 0000000..0c2dcca
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+  !!DESCRIPTION!! Getting the size of a void-type variable (cc65 extension)
+  !!ORIGIN!!      cc65 regression tests
+  !!LICENCE!!     Public Domain
+  !!AUTHOR!!      Greg King
+*/
+
+static const void list1 = {
+    (char)1,
+    (char)2,
+    (char)3,
+    (char)4,
+    (char)5,
+    (char)6,
+    (char)7,
+    (char)8,
+    (char)9,
+    (char)0
+};
+
+static void list2 = {
+    1,
+    2,
+    3,
+    4,
+    5,
+    6,
+    7,
+    8,
+    9,
+    0
+};
+
+void list3 = {
+    (char)1,
+    (char)2,
+    (char)3,
+    (char)4,
+    &list1,
+    (char)6,
+    (char)7,
+    (char)8,
+    (char)9,
+    &list2
+};
+
+/* We know that the expression is constant; don't tell us. */
+
+#pragma warn (const-comparison, off)
+
+int main (void)
+{
+    return sizeof list1 != 10
+        || sizeof list2 != 20
+        || sizeof list3 != 12;
+}
index cf21470528bf7a244a4800556f1dc280e2a15407..b86b1fba59afb11e308702bf462fda686d57a30a 100644 (file)
 /*
-  !!DESCRIPTION!!
+  !!DESCRIPTION!! while-condition tests
   !!ORIGIN!!      SDCC regression tests
   !!LICENCE!!     GPL, read COPYING.GPL
 */
 
 #include <stdio.h>
-#include <limits.h>
-
-unsigned char success = 0;
-unsigned char failures = 0;
-unsigned char dummy = 0;
-
-#ifdef SUPPORT_BIT_TYPES
-bit bit0 = 0;
-#endif
-unsigned int aint0 = 0;
-unsigned int aint1 = 0;
-unsigned char achar0 = 0;
-unsigned char achar1 = 0;
-
-void
-done ()
+
+static unsigned char failures = 0x00;
+static unsigned char achar0 = 0;
+
+static void
+while1 (void)
 {
-  dummy++;
+  unsigned char i = 10;
+
+  do {
+    ++achar0;
+  } while (--i);
+
+  if (achar0 != 10) {
+    failures |= 0x01;
+  }
 }
 
-void
-while1 (void)
+static void
+while2 (void)
 {
   unsigned char i = 10;
 
-  do
-    {
-      achar0++;
+  achar0 = 0;
+  while (--i) {
+    ++achar0;
+  }
+
+  if (achar0 != 10 - 1) {
+    failures |= 0x02;
+  }
+}
+
+static void
+while3 (void)
+{
+  achar0 = 0;
+  do {
+    if (++achar0 == (unsigned char)0) {
+      return;
     }
-  while (--i);
+  } while (1);
 
-  if (achar0 != 10)
-    failures++;
+  failures |= 0x04;
+}
+
+static void
+while4 (void)
+{
+  achar0 = 0;
+  while (1) {
+    if (++achar0 == (unsigned char)0) {
+      return;
+    }
+  }
+
+  failures |= 0x08;
+}
+
+static void
+while5 (void)
+{
+  achar0 = 0;
+  do {
+    ++achar0;
+  } while (0);
+
+  if (achar0 != 1) {
+    failures |= 0x10;
+  }
+}
+
+static void
+while6 (void)
+{
+  achar0 = 0;
+  while (0) {
+    ++achar0;
+  }
+
+  if (achar0 != 1 - 1) {
+    failures |= 0x20;
+  }
 }
 
 int
 main (void)
 {
   while1 ();
+  while2 ();
+  while3 ();
+  while4 ();
+  while5 ();
+  while6 ();
 
-  success = failures;
-  done ();
-  printf("failures: %d\n",failures);
-
+  if (failures) {
+    printf("failures: 0x%02X\n", failures);
+  }
   return failures;
 }
index 04c5998786eb1cddb1b1c5f4c56af9ab5b82afd3..ae1931e64df042ede5534102349a44ed596a98a4 100644 (file)
@@ -1,59 +1,55 @@
 /*
-** testprogram for ANTIC instructions as defined in "_antic.h"
+** test program for ANTIC instructions as defined in "_antic.h"
 **
 ** 23-Feb-2017, Christian Krueger
 */
 
 #include <conio.h>
 #include <atari.h>
-#include <peekpoke.h>
-#include <string.h>
 
-// code is only for testing purposes, as screen and display list are not aligned
+// code is only for testing purposes, as screen and display list are not aligned,
 // and jumps not set!
 
 unsigned char DummyScreen[400];
 
 void DisplayList = {
-       DL_BLK1,
-       DL_BLK2,
-       DL_BLK3,
-       DL_BLK4,
-       DL_BLK5,
-       DL_BLK6,
-       DL_BLK7,
-       DL_DLI(DL_BLK8),
-       DL_LMS(DL_CHR40x8x1),
-       DummyScreen,
-       DL_HSCROL(DL_CHR40x10x1),
-       DL_VSCROL(DL_CHR40x8x4),
-       DL_CHR40x16x4,
-       DL_LMS(DL_HSCROL(DL_VSCROL(DL_DLI(DL_CHR20x8x2)))),
-       DummyScreen+120,
-       DL_CHR20x16x2,
-       DL_MAP40x8x4,
-       DL_MAP80x4x2,
-       DL_MAP80x4x4,
-       DL_MAP160x2x2,
-       DL_MAP160x1x2,
-       DL_MAP160x2x4,
-       DL_MAP160x1x4,
-       DL_MAP320x1x1, 
-       DL_JVB,
-       DL_JMP
+    DL_BLK1,
+    DL_BLK2,
+    DL_BLK3,
+    DL_BLK4,
+    DL_BLK5,
+    DL_BLK6,
+    DL_BLK7,
+    DL_DLI(DL_BLK8),
+    DL_LMS(DL_CHR40x8x1),
+    DummyScreen,
+    DL_HSCROL(DL_CHR40x10x1),
+    DL_VSCROL(DL_CHR40x8x4),
+    DL_CHR40x16x4,
+    DL_LMS(DL_HSCROL(DL_VSCROL(DL_DLI(DL_CHR20x8x2)))),
+    DummyScreen+120,
+    DL_CHR20x16x2,
+    DL_MAP40x8x4,
+    DL_MAP80x4x2,
+    DL_MAP80x4x4,
+    DL_MAP160x2x2,
+    DL_MAP160x1x2,
+    DL_MAP160x2x4,
+    DL_MAP160x1x4,
+    DL_MAP320x1x1,
+    DL_JVB,
+    DL_JMP
 };
 
-unsigned char dlend = 0;
 
+/* We know that the sizeof expression is constant; don't tell us. */
+
+#pragma warn (const-comparison, off)
 
 int
 main(void)
 {
-    // unfortunately "sizeof()" doesn't work with void data
-    // (Error: Size of data type is unknown)
-    // so we trick with the addresses at front and end...
-
-    int returnValue = (((unsigned int)&dlend-(unsigned int)&DisplayList) != 28);  // assure only one byte per instruction!
+    int returnValue = (sizeof DisplayList != 28);       // assure only one byte per instruction!
 
     clrscr();
     if (returnValue)
@@ -66,4 +62,3 @@ main(void)
 
     return returnValue;
 }
-
index fe977ec08ca2d11f45a7a32deb6e2359959732b7..13188d1cda650e9bf30d4605c637037b39c07a2b 100644 (file)
@@ -117,8 +117,8 @@ void main(void)
                 gotoxy(7 + inpos,1);
 
 #if defined(__NES__) || defined(__PCE__) || defined(__GAMATE__)
-                /* not all targets have waitvblank */
-                waitvblank();
+                /* not all targets have waitvsync */
+                waitvsync();
                 /* for targets that do not have a keyboard, read the first
                    joystick */
                 joy = joy_read(JOY_1);
index dfebd9befc8a12e31db163bbb96a0e0415554a4d..793770cee5615971b65adb75f55f819a18f3e8fd 100644 (file)
@@ -41,7 +41,7 @@ int main(int argc, char *argv[])
                 break;
         }
 
-        waitvblank();
+        waitvsync();
 
         (*((unsigned char*)LCD_XPOS)) = x;
         (*((unsigned char*)LCD_YPOS)) = y;
index fc751ebdcfa6d7f1b9e557b8e5623ea92ecb551f..fdd83bb4e2944f9de98c6c12dd61f7cf9a7885be 100644 (file)
@@ -58,21 +58,19 @@ int main (void)
 #if defined(__ATARI5200__) || defined(__CREATIVISION__)
             cprintf ("%1d:%-3s%-3s%-3s%-3s%-3s%-3s",
                      i,
-                     (j & joy_masks[JOY_UP])?    " U " : "   ",
-                     (j & joy_masks[JOY_DOWN])?  " D " : "   ",
-                     (j & joy_masks[JOY_LEFT])?  " L " : "   ",
-                     (j & joy_masks[JOY_RIGHT])? " R " : "   ",
-                     (j & joy_masks[JOY_FIRE])?  " 1 " : "   ",
-                     (j & joy_masks[JOY_FIRE2])? " 2 " : "   ");
+                     JOY_UP(j)?    " U " : " - ",
+                     JOY_DOWN(j)?  " D " : " - ",
+                     JOY_LEFT(j)?  " L " : " - ",
+                     JOY_RIGHT(j)? " R " : " - ",
+                     JOY_BTN_1(j)? " 1 " : " - ");
 #else
             cprintf ("%2d: %-6s%-6s%-6s%-6s%-6s%-6s",
                      i,
-                     (j & joy_masks[JOY_UP])?    "  up  " : " ---- ",
-                     (j & joy_masks[JOY_DOWN])?  " down " : " ---- ",
-                     (j & joy_masks[JOY_LEFT])?  " left " : " ---- ",
-                     (j & joy_masks[JOY_RIGHT])? "right " : " ---- ",
-                     (j & joy_masks[JOY_FIRE])?  " fire " : " ---- ",
-                     (j & joy_masks[JOY_FIRE2])? "fire2 " : " ---- ");
+                     JOY_UP(j)?    "  up  " : " ---- ",
+                     JOY_DOWN(j)?  " down " : " ---- ",
+                     JOY_LEFT(j)?  " left " : " ---- ",
+                     JOY_RIGHT(j)? "right " : " ---- ",
+                     JOY_BTN_1(j)? "button" : " ---- ");
 #endif
         }
     }
index 2daf5aa062f03928eca6789225557aabe7685e82..f9db3f641a8f19a8fed601e1e8376dbbb29c521a 100644 (file)
-/* mul-test.c -- Test the multiplication operator. */\r
-\r
-#include <time.h>\r
-#include <conio.h>\r
-#include <ctype.h>\r
-\r
-\r
-/* Number of elements in the progress bar. Use a power of 2, to avoid the\r
-** multiplication (which is about to be tested).\r
-*/\r
-#define BAR_ELEMENTS    32U\r
-\r
-#if defined(__CBM__)\r
-static const unsigned char revers_bar[8] = {\r
-    0, 0, 0, 0, 0, 1, 1, 1\r
-};\r
-static const unsigned char small_bar[8] = {\r
-    ' ', 0xa5, 0xb4, 0xb5, 0xa1, 0xb6, 0xaa, 0xa7\r
-};\r
-\r
-#elif defined(__ATARI__)\r
-#endif\r
-\r
-/* Screen co-ordinates for the progress meter */\r
-static unsigned char Width, Height;\r
-static unsigned char X, Y;\r
-\r
-static void ProgressMeter (unsigned Val)\r
-/* Print the progress bar. */\r
-{\r
-    gotoxy (X, Y);\r
-    cprintf (" %5lu/65536\r\n", (unsigned long) Val);\r
-    revers (1);\r
-    cclear (Val / (unsigned)(65536U / BAR_ELEMENTS));\r
-\r
-/* Commodore and Atari computers can show eight times greater precision. */\r
-#if defined(__CBM__)\r
-    Val = (Val / (unsigned)(65536U / BAR_ELEMENTS / 8)) % 8;\r
-    revers (revers_bar[Val]);\r
-    cputc (small_bar[Val]);\r
-\r
-#elif defined(__ATARI__)\r
-#endif\r
-\r
-    revers (0);\r
-}\r
-\r
-\r
-\r
-int main(void)\r
-{\r
-    char C;\r
-\r
-    /* Clock variables */\r
-    clock_t Ticks;\r
-    clock_t Wait;\r
-    unsigned Days;\r
-    unsigned Hours;\r
-    unsigned Minu;\r
-    unsigned Sec;\r
-    unsigned Milli;\r
-\r
-    /* Actual test variables */\r
-    register unsigned lhs = 0;\r
-    register unsigned rhs = 0;\r
-    register unsigned res;\r
-\r
-    /* Clear the screen, and output an informational message. */\r
-    clrscr ();\r
-    screensize (&Width, &Height);\r
-    cprintf ("This program does an exhaustive test of\r\n"\r
-             "the multiplication routine. It runs for\r\n"\r
-             "several days; so, please wait very\r\n"\r
-             "patiently (or, speed up your emulator).\r\n"\r
-             "\n"\r
-             "Progress: ");\r
-\r
-    /* Remember the current position for the progress bar */\r
-    X = wherex ();\r
-    Y = wherey ();\r
-\r
-    /* Mark the maximum limit of the bar. */\r
-    revers (1);\r
-    cputcxy (BAR_ELEMENTS, Y, ' ');\r
-    cputcxy (BAR_ELEMENTS, Y + 1, ' ');\r
-    revers (0);\r
-\r
-/* [Targets that have clock() will define CLOCKS_PER_SEC.] */\r
-#ifdef CLOCKS_PER_SEC\r
-\r
-    /* Start timing the test. */\r
-    Ticks = clock();\r
-#endif\r
-\r
-    do {\r
-\r
-        /* Update the progress bar */\r
-        ProgressMeter (lhs);\r
-\r
-/* Enable this to test the progress-meter code.\r
-** (And, run emulators at their maximun speed.)\r
-*/\r
-#if 0\r
-        continue;\r
-#endif\r
-\r
-        /* Do one row of tests */\r
-        res = 0;\r
-        do {\r
-            if (lhs * rhs != res) {\r
-#ifdef CLOCKS_PER_SEC\r
-                Wait = clock ();\r
-#endif\r
-                gotoxy (0, Y+3);\r
-                cprintf ("Error on %u * %u: %u != %u\r\n", lhs, rhs, lhs * rhs, res);\r
-                cprintf ("Press a key -- 'Q' to quit. ");\r
-                cursor (1);\r
-                C = toupper (cgetc ());\r
-                cclearxy (0, Y+3, Width);\r
-                cclearxy (0, Y+4, Width);\r
-\r
-#ifdef CLOCKS_PER_SEC\r
-\r
-                /* Don't time the user's interaction. */\r
-                Ticks += clock () - Wait;\r
-#endif\r
-\r
-                if (C == 'Q') {\r
-                    goto Done;\r
-                }\r
-            }\r
-\r
-            if (kbhit () && toupper (cgetc ()) == 'Q') {\r
-                goto Done;\r
-            }\r
-\r
-            res += lhs;\r
-        } while (++rhs != 0);\r
-\r
-    } while (++lhs != 0);\r
-\r
-Done:\r
-#ifdef CLOCKS_PER_SEC\r
-\r
-    /* Calculate the time used */\r
-    Ticks = clock() - Ticks;\r
-    Milli = ((Ticks % CLOCKS_PER_SEC) * 1000) / CLOCKS_PER_SEC;\r
-    Sec = (unsigned) (Ticks / CLOCKS_PER_SEC);\r
-    Minu = Sec / 60;\r
-    Hours = Minu / 60;\r
-    Days = Hours / 24;\r
-    Hours %= 24;\r
-    Minu %= 60;\r
-    Sec %= 60;\r
-\r
-    /* Print the time used */\r
-    gotoxy (0, Y+3);\r
-    cprintf ("Time used:\r\n"\r
-             " %u days,\r\n"\r
-             " %u hours,\r\n"\r
-             " %u minutes,\r\n"\r
-             " %u.%03u seconds.\n", Days, Hours, Minu, Sec, Milli);\r
-#endif\r
-\r
-    cprintf ("\rTap a key, to exit. ");\r
-    cgetc();\r
-    return 0;\r
-}\r
-\r
-\r
+/* mul-test.c -- Test the multiplication operator. */
+
+#include <time.h>
+#include <conio.h>
+#include <ctype.h>
+
+
+/* Number of elements in the progress bar. Use a power of 2, to avoid the
+** multiplication (which is about to be tested).
+*/
+#define BAR_ELEMENTS    32U
+
+#if defined(__CBM__)
+static const unsigned char revers_bar[8] = {
+    0, 0, 0, 0, 0, 1, 1, 1
+};
+static const unsigned char small_bar[8] = {
+    ' ', 0xa5, 0xb4, 0xb5, 0xa1, 0xb6, 0xaa, 0xa7
+};
+
+#elif defined(__ATARI__)
+#endif
+
+/* Screen co-ordinates for the progress meter */
+static unsigned char Width, Height;
+static unsigned char X, Y;
+
+static void ProgressMeter (unsigned Val)
+/* Print the progress bar. */
+{
+    gotoxy (X, Y);
+    cprintf (" %5lu/65536\r\n", (unsigned long) Val);
+    revers (1);
+    cclear (Val / (unsigned)(65536U / BAR_ELEMENTS));
+
+/* Commodore and Atari computers can show eight times greater precision. */
+#if defined(__CBM__)
+    Val = (Val / (unsigned)(65536U / BAR_ELEMENTS / 8)) % 8;
+    revers (revers_bar[Val]);
+    cputc (small_bar[Val]);
+
+#elif defined(__ATARI__)
+#endif
+
+    revers (0);
+}
+
+
+
+int main(void)
+{
+    char C;
+
+    /* Clock variables */
+    clock_t Ticks;
+    clock_t Wait;
+    unsigned Days;
+    unsigned Hours;
+    unsigned Minu;
+    unsigned Sec;
+    unsigned Milli;
+
+    /* Actual test variables */
+    register unsigned lhs = 0;
+    register unsigned rhs = 0;
+    register unsigned res;
+
+    /* Clear the screen, and output an informational message. */
+    clrscr ();
+    screensize (&Width, &Height);
+    cprintf ("This program does an exhaustive test of\r\n"
+             "the multiplication routine. It runs for\r\n"
+             "several days; so, please wait very\r\n"
+             "patiently (or, speed up your emulator).\r\n"
+             "\n"
+             "Progress: ");
+
+    /* Remember the current position for the progress bar */
+    X = wherex ();
+    Y = wherey ();
+
+    /* Mark the maximum limit of the bar. */
+    revers (1);
+    cputcxy (BAR_ELEMENTS, Y, ' ');
+    cputcxy (BAR_ELEMENTS, Y + 1, ' ');
+    revers (0);
+
+/* [Targets that have clock() will define CLOCKS_PER_SEC.] */
+#ifdef CLOCKS_PER_SEC
+
+    /* Start timing the test. */
+    Ticks = clock();
+#endif
+
+    do {
+
+        /* Update the progress bar */
+        ProgressMeter (lhs);
+
+/* Enable this to test the progress-meter code.
+** (And, run emulators at their maximun speed.)
+*/
+#if 0
+        continue;
+#endif
+
+        /* Do one row of tests */
+        res = 0;
+        do {
+            if (lhs * rhs != res) {
+#ifdef CLOCKS_PER_SEC
+                Wait = clock ();
+#endif
+                gotoxy (0, Y+3);
+                cprintf ("Error on %u * %u: %u != %u\r\n", lhs, rhs, lhs * rhs, res);
+                cprintf ("Press a key -- 'Q' to quit. ");
+                cursor (1);
+                C = toupper (cgetc ());
+                cclearxy (0, Y+3, Width);
+                cclearxy (0, Y+4, Width);
+
+#ifdef CLOCKS_PER_SEC
+
+                /* Don't time the user's interaction. */
+                Ticks += clock () - Wait;
+#endif
+
+                if (C == 'Q') {
+                    goto Done;
+                }
+            }
+
+            if (kbhit () && toupper (cgetc ()) == 'Q') {
+                goto Done;
+            }
+
+            res += lhs;
+        } while (++rhs != 0);
+
+    } while (++lhs != 0);
+
+Done:
+#ifdef CLOCKS_PER_SEC
+
+    /* Calculate the time used */
+    Ticks = clock() - Ticks;
+    Milli = ((Ticks % CLOCKS_PER_SEC) * 1000) / CLOCKS_PER_SEC;
+    Sec = (unsigned) (Ticks / CLOCKS_PER_SEC);
+    Minu = Sec / 60;
+    Hours = Minu / 60;
+    Days = Hours / 24;
+    Hours %= 24;
+    Minu %= 60;
+    Sec %= 60;
+
+    /* Print the time used */
+    gotoxy (0, Y+3);
+    cprintf ("Time used:\r\n"
+             " %u days,\r\n"
+             " %u hours,\r\n"
+             " %u minutes,\r\n"
+             " %u.%03u seconds.\n", Days, Hours, Minu, Sec, Milli);
+#endif
+
+    cprintf ("\rTap a key, to exit. ");
+    cgetc();
+    return 0;
+}
+
+
index a4bd63b153d03131ea4b57338e9a8816beccc85c..ed3f86240446984b2250c54d2ae6a4337d82f440 100644 (file)
@@ -1,3 +1,4 @@
+#include <pce.h>
 #include <conio.h>
 #include <time.h>
 #include <joystick.h>
@@ -97,14 +98,14 @@ void main(void)
                         j = joy_read (i);
                         cprintf ("pad %d: %02x %-6s%-6s%-6s%-6s%-6s%-6s%-6s%-6s",
                                 i, j,
-                                (j & joy_masks[JOY_UP])?    "  up  " : " ---- ",
-                                (j & joy_masks[JOY_DOWN])?  " down " : " ---- ",
-                                (j & joy_masks[JOY_LEFT])?  " left " : " ---- ",
-                                (j & joy_masks[JOY_RIGHT])? "right " : " ---- ",
-                                (j & joy_masks[JOY_FIRE])?  " fire " : " ---- ",
-                                (j & joy_masks[JOY_FIRE2])? "fire2 " : " ---- ",
-                                (j & joy_masks[JOY_SELECT])? "select" : " ---- ",
-                                (j & joy_masks[JOY_RUN])?   " run  " : " ---- ");
+                                JOY_UP(j)?     "  up  " : " ---- ",
+                                JOY_DOWN(j)?   " down " : " ---- ",
+                                JOY_LEFT(j)?   " left " : " ---- ",
+                                JOY_RIGHT(j)?  "right " : " ---- ",
+                                JOY_BTN_I(j)?  "btn I " : " ---- ",
+                                JOY_BTN_II(j)? "btn II" : " ---- ",
+                                JOY_SELECT(j)? "select" : " ---- ",
+                                JOY_RUN(j)?    " run  " : " ---- ");
                 }
 
                 gotoxy(xsize - 10, 3);
@@ -123,7 +124,7 @@ void main(void)
                                 p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
                 }
 
-                waitvblank();
+                waitvsync();
                 ++n;
         }
 }
diff --git a/testcode/lib/strchr-test.c b/testcode/lib/strchr-test.c
deleted file mode 100644 (file)
index 7aba1de..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-
-                                                        
-/* Test string. Must NOT have duplicate characters! */
-static char S[] = "Helo wrd!\n";
-
-static char Found[256];
-
-
-
-int main (void)
-{
-    unsigned Len;
-    unsigned I;
-    char*    P;
-
-    /* Print a header */
-    printf ("strchr(): ");
-
-    /* Get the length of the string */
-    Len = strlen (S);
-
-    /* Search for all characters in the string, including the terminator */
-    for (I = 0; I < Len+1; ++I) {
-
-        /* Search for this char */
-        P = strchr (S, S[I]);
-
-        /* Check if we found it */
-        if (P == 0 || (P - S) != I) {
-            printf ("Failed for code 0x%02X, offset %u!\n", S[I], I);
-            printf ("P = %04X offset = %04X\n", P, P-S);
-            exit (EXIT_FAILURE);
-        }
-
-        /* Mark the char as checked */
-        Found[S[I]] = 1;
-    }
-
-    /* Search for all other characters and make sure they aren't found */
-    for (I = 0; I < 256; ++I) {
-        if (Found[I] == 0) {
-            if (strchr (S, (char)I) != 0) {
-                printf ("Failed for code 0x%02X\n", I);
-                exit (EXIT_FAILURE);
-            }
-        }
-    }
-
-    /* Test passed */
-    printf ("Passed\n");
-    return EXIT_SUCCESS;
-}
-
-
-