Merge remote-tracking branch 'upstream/master' into creativision

This commit is contained in:
Christian Groessler
2017-02-01 18:15:05 +01:00
404 changed files with 8404 additions and 3086 deletions

View File

@@ -1,3 +1,4 @@
ifneq ($(shell echo),)
CMD_EXE = 1
endif
@@ -18,6 +19,7 @@ TARGETS = apple2 \
apple2enh \
atari \
atarixl \
atari2600 \
atari5200 \
atmos \
creativision \
@@ -38,13 +40,13 @@ DRVTYPES = emd \
ser \
tgi
OUTPUTDIRS := lib \
$(DRVTYPES) \
targetutil \
asminc \
cfg \
include \
$(subst ../,,$(filter-out $(wildcard ../include/*.*),$(wildcard ../include/*)))
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)
@@ -78,7 +80,7 @@ mostlyclean:
$(call RMDIR,../libwrk)
clean:
$(call RMDIR,../libwrk ../lib ../targetutil $(addprefix ../,$(DRVTYPES)))
$(call RMDIR,../libwrk ../lib ../target)
ifdef CMD_EXE
@@ -92,7 +94,7 @@ define INSTALL_recipe
$(if $(prefix),,$(error variable `prefix' must be set))
$(INSTALL) -d $(DESTDIR)$(datadir)/$(dir)
$(INSTALL) -m644 ../$(dir)/*.* $(DESTDIR)$(datadir)/$(dir)
$(INSTALL) -m0644 ../$(dir)/*.* $(DESTDIR)$(datadir)/$(dir)
endef # INSTALL_recipe
@@ -213,7 +215,7 @@ define DRVTYPE_template
$1_SRCDIR = $$(SRCDIR)/$1
$1_STCDIR = ../libwrk/$$(TARGET)
$1_DYNDIR = ../libwrk/$$(TARGET)/$1
$1_DRVDIR = ../$1
$1_DRVDIR = ../target/$$(TARGET)/drv/$1
$1_SRCPAT = $$($1_SRCDIR)/$$(OBJPFX)%.s
$1_STCPAT = $$($1_STCDIR)/$$(OBJPFX)%-$1.o
@@ -284,7 +286,7 @@ $(EXTRA_OBJPAT): $(EXTRA_SRCPAT) | ../lib
../lib/$(TARGET).lib: $(OBJS) | ../lib
$(AR65) a $@ $?
../libwrk/$(TARGET) ../lib ../targetutil:
../libwrk/$(TARGET) ../lib ../target/$(TARGET)/util:
@$(call MKDIR,$@)
$(TARGET): $(EXTRA_OBJS) ../lib/$(TARGET).lib

81
libsrc/apple2/_sys.s Normal file
View File

@@ -0,0 +1,81 @@
;
; void __fastcall__ _sys (struct regs* r);
;
.export __sys
.import jmpvec
.include "zeropage.inc"
.segment "LOWCODE"
__sys: sta ptr1
stx ptr1+1 ; Save the pointer to r
; Fetch the PC and store it into the jump vector
ldy #5
lda (ptr1),y
sta jmpvec+2
dey
lda (ptr1),y
sta jmpvec+1
; Remember the flags so we can restore them to a known state after calling the
; routine
php
; Get the flags, keep the state of bit 4 and 5 using the other flags from
; the flags value passed by the caller. Push the new flags and push A.
dey
php
pla ; Current flags -> A
eor (ptr1),y
and #%00110000
eor (ptr1),y
pha ; Push new flags value
ldy #0
lda (ptr1),y
pha
; Get and assign X and Y
iny
lda (ptr1),y
tax
iny
lda (ptr1),y
tay
; Switch in ROM
bit $C082
; Set A and the flags, call the machine code routine
pla
plp
jsr jmpvec
; Back from the routine. Save the flags and A.
php
pha
; Switch in LC bank 2 for R/O
bit $C080
; Put the register values into the regs structure
tya
ldy #2
sta (ptr1),y
dey
txa
sta (ptr1),y
dey
pla
sta (ptr1),y
ldy #3
pla
sta (ptr1),y
; Restore the old flags value
plp
; Done
rts

View File

@@ -6,12 +6,11 @@
;
.export _cclearxy, _cclear
.import popa, _gotoxy, chlinedirect
.import gotoxy, chlinedirect
_cclearxy:
pha ; Save the length
jsr popa ; Get y
jsr _gotoxy ; Call this one, will pop params
jsr gotoxy ; Call this one, will pop params
pla ; Restore the length and run into _cclear
_cclear:

View File

@@ -6,20 +6,44 @@
; If open_apple key is pressed then the high-bit of the key is set.
;
.export _cgetc
.export _cgetc
.import cursor, putchardirect
.include "apple2.inc"
.include "apple2.inc"
_cgetc:
lda KBD
bpl _cgetc ; If < 128, no key pressed
; Cursor on ?
lda cursor
beq :+
; At this time, the high bit of the key pressed is set
bit KBDSTRB ; Clear keyboard strobe
; Show caret.
.ifdef __APPLE2ENH__
lda #$7F | $80 ; Checkerboard, screen code
.else
lda #' ' | $40 ; Blank, flashing
.endif
jsr putchardirect ; Returns old character in X
; Wait for keyboard strobe.
: lda KBD
bpl :- ; If < 128, no key pressed
; Cursor on ?
ldy cursor
beq :+
; Restore old character.
pha
txa
jsr putchardirect
pla
; At this time, the high bit of the key pressed is set.
: bit KBDSTRB ; Clear keyboard strobe
.ifdef __APPLE2ENH__
bit BUTN0 ; Check if OpenApple is down
bmi done
.endif
and #$7F ; If not down, then clear high bit
done: ldx #$00
done: ldx #>$0000
rts

View File

@@ -6,15 +6,14 @@
;
.export _chlinexy, _chline, chlinedirect
.import popa, _gotoxy, cputdirect
.import gotoxy, cputdirect
.include "zeropage.inc"
.include "apple2.inc"
_chlinexy:
pha ; Save the length
jsr popa ; Get y
jsr _gotoxy ; Call this one, will pop params
jsr gotoxy ; Call this one, will pop params
pla ; Restore the length and run into _chline
_chline:
@@ -27,11 +26,12 @@ _chline:
ldx #'-' | $80 ; Horizontal line, screen code
chlinedirect:
stx tmp1
cmp #$00 ; Is the length zero?
beq done ; Jump if done
sta tmp1
: txa ; Screen code
sta tmp2
: lda tmp1 ; Screen code
jsr cputdirect ; Direct output
dec tmp1
dec tmp2
bne :-
done: rts

View File

@@ -9,12 +9,12 @@
.constructor initconio
.endif
.export _cputcxy, _cputc
.export cputdirect, newline, putchar
.import popa, _gotoxy, VTABZ
.export cputdirect, newline, putchar, putchardirect
.import gotoxy, VTABZ
.include "apple2.inc"
.segment "INIT"
.segment "ONCE"
.ifdef __APPLE2ENH__
initconio:
@@ -29,9 +29,8 @@ initconio:
_cputcxy:
pha ; Save C
jsr popa ; Get Y
jsr _gotoxy
pla ; Restore C
jsr gotoxy ; Call this one, will pop params
pla ; Restore C and run into _cputc
_cputc:
cmp #$0D ; Test for \r = carrage return
@@ -63,32 +62,36 @@ newline:
lda WNDTOP ; Goto top of screen
sta CV
: jmp VTABZ
putchar:
.ifdef __APPLE2ENH__
ldy INVFLG
cpy #$FF ; Normal character display mode?
beq put
beq putchardirect
cmp #$E0 ; Lowercase?
bcc mask
and #$7F ; Inverse lowercase
bra put
bra putchardirect
.endif
mask: and INVFLG ; Apply normal, inverse, flash
put: ldy CH
putchardirect:
pha
ldy CH
.ifdef __APPLE2ENH__
bit RD80VID ; In 80 column mode?
bpl col40 ; No, in 40 cols
pha
bpl put ; No, just go ahead
tya
lsr ; Div by 2
tay
pla
bcs col40 ; Odd cols go in 40 col memory
bcs put ; Odd cols go in main memory
bit HISCR ; Assume SET80COL
sta (BASL),Y
bit LOWSCR ; Assume SET80COL
rts
.endif
col40: sta (BASL),Y
put: lda (BASL),Y ; Get current character
tax ; Return old character for _cgetc
pla
sta (BASL),Y
.ifdef __APPLE2ENH__
bit LOWSCR ; Doesn't hurt in 40 column mode
.endif
rts

View File

@@ -6,16 +6,17 @@
.export _exit, done, return
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import zerobss
.import initlib, donelib
.import callmain
.import zerobss, callmain
.import __ONCE_LOAD__, __ONCE_SIZE__ ; Linker generated
.import __LC_START__, __LC_LAST__ ; Linker generated
.import __INIT_RUN__, __INIT_SIZE__ ; Linker generated
.import __INITBSS_RUN__ ; Linker generated
.include "zeropage.inc"
.include "apple2.inc"
; ------------------------------------------------------------------------
.segment "STARTUP"
; ProDOS TechRefMan, chapter 5.2.1:
@@ -24,57 +25,16 @@
ldx #$FF
txs ; Init stack pointer
; Switch in LC bank 2 for W/O.
bit $C081
bit $C081
; Set the source start address.
lda #<(__INITBSS_RUN__ + __INIT_SIZE__)
ldy #>(__INITBSS_RUN__ + __INIT_SIZE__)
sta $9B
sty $9C
; Set the source last address.
lda #<(__INITBSS_RUN__ + __INIT_SIZE__ + __LC_LAST__ - __LC_START__)
ldy #>(__INITBSS_RUN__ + __INIT_SIZE__ + __LC_LAST__ - __LC_START__)
sta $96
sty $97
; Set the destination last address.
lda #<__LC_LAST__
ldy #>__LC_LAST__
sta $94
sty $95
; Call into Applesoft Block Transfer Up -- which handles zero-
; sized blocks well -- to move the content of the LC memory area.
jsr $D39A ; BLTU2
; Set the source start address.
lda #<__INITBSS_RUN__
ldy #>__INITBSS_RUN__
sta $9B
sty $9C
; Set the source last address.
lda #<(__INITBSS_RUN__ + __INIT_SIZE__)
ldy #>(__INITBSS_RUN__ + __INIT_SIZE__)
sta $96
sty $97
; Set the destination last address.
lda #<(__INIT_RUN__ + __INIT_SIZE__)
ldy #>(__INIT_RUN__ + __INIT_SIZE__)
sta $94
sty $95
; Call into Applesoft Block Transfer Up -- which handles moving
; overlapping blocks upwards well -- to move the INIT segment.
jsr $D39A ; BLTU2
; Delegate all further processing, to keep the STARTUP segment small.
; Save space by putting some of the start-up code in the ONCE segment,
; which can be re-used by the BSS segment, the heap and the C stack.
jsr init
; Clear the BSS data.
jsr zerobss
; Push the command-line arguments; and, call main().
jsr callmain
; Avoid a re-entrance of donelib. This is also the exit() entry.
_exit: ldx #<exit
lda #>exit
@@ -109,7 +69,9 @@ exit: ldx #$02
; We're done
jmp done
.segment "INIT"
; ------------------------------------------------------------------------
.segment "ONCE"
; Save the zero-page locations that we need.
init: ldx #zpspace-1
@@ -118,9 +80,6 @@ init: ldx #zpspace-1
dex
bpl :-
; Clear the BSS data.
jsr zerobss
; Save the original RESET vector.
ldx #$02
: lda SOFTEV,x
@@ -128,13 +87,6 @@ init: ldx #zpspace-1
dex
bpl :-
; ProDOS TechRefMan, chapter 5.3.5:
; "Your system program should place in the RESET vector the
; address of a routine that ... closes the files."
ldx #<_exit
lda #>_exit
jsr reset ; Setup RESET vector
; Check for ProDOS.
ldy $BF00 ; MLI call entry point
cpy #$4C ; Is MLI present? (JMP opcode)
@@ -164,14 +116,50 @@ basic: lda HIMEM
: sta sp
stx sp+1
; ProDOS TechRefMan, chapter 5.3.5:
; "Your system program should place in the RESET vector the
; address of a routine that ... closes the files."
ldx #<_exit
lda #>_exit
jsr reset ; Setup RESET vector
; Call the module constructors.
jsr initlib
; Switch in LC bank 2 for R/O.
bit $C080
; Switch in LC bank 2 for W/O.
bit $C081
bit $C081
; Push the command-line arguments; and, call main().
jmp callmain
; Set the source start address.
; Aka __LC_LOAD__ iff segment LC exists.
lda #<(__ONCE_LOAD__ + __ONCE_SIZE__)
ldy #>(__ONCE_LOAD__ + __ONCE_SIZE__)
sta $9B
sty $9C
; Set the source last address.
; Aka __LC_LOAD__ + __LC_SIZE__ iff segment LC exists.
lda #<((__ONCE_LOAD__ + __ONCE_SIZE__) + (__LC_LAST__ - __LC_START__))
ldy #>((__ONCE_LOAD__ + __ONCE_SIZE__) + (__LC_LAST__ - __LC_START__))
sta $96
sty $97
; Set the destination last address.
; Aka __LC_RUN__ + __LC_SIZE__ iff segment LC exists.
lda #<__LC_LAST__
ldy #>__LC_LAST__
sta $94
sty $95
; Call into Applesoft Block Transfer Up -- which handles zero-
; sized blocks well -- to move the content of the LC memory area.
jsr $D39A ; BLTU2
; Switch in LC bank 2 for R/O and return.
bit $C080
rts
; ------------------------------------------------------------------------
.code
@@ -187,6 +175,8 @@ quit: jsr $BF00 ; MLI call entry point
.byte $65 ; Quit
.word q_param
; ------------------------------------------------------------------------
.rodata
; MLI parameter list for quit
@@ -196,15 +186,16 @@ q_param:.byte $04 ; param_count
.byte $00 ; reserved
.word $0000 ; reserved
; ------------------------------------------------------------------------
.data
; Final jump when we're done
done: jmp DOSWARM ; Potentially patched at runtime
.segment "INITBSS"
; ------------------------------------------------------------------------
.segment "INIT"
zpsave: .res zpspace
.bss
rvsave: .res 3

View File

@@ -6,14 +6,13 @@
;
.export _cvlinexy, _cvline, cvlinedirect
.import popa, _gotoxy, putchar, newline
.import gotoxy, putchar, newline
.include "zeropage.inc"
_cvlinexy:
pha ; Save the length
jsr popa ; Get y
jsr _gotoxy ; Call this one, will pop params
jsr gotoxy ; Call this one, will pop params
pla ; Restore the length and run into _cvline
_cvline:
@@ -24,12 +23,13 @@ _cvline:
.endif
cvlinedirect:
stx tmp1
cmp #$00 ; Is the length zero?
beq done ; Jump if done
sta tmp1
: txa ; Screen code
sta tmp2
: lda tmp1 ; Screen code
jsr putchar ; Write, no cursor advance
jsr newline ; Advance cursor to next line
dec tmp1
dec tmp2
bne :-
done: rts

View File

@@ -0,0 +1,21 @@
;
; Oliver Schmidt, 2016-06-05
;
; unsigned char doesclrscrafterexit (void);
;
.export _doesclrscrafterexit
.import done
.include "apple2.inc"
_doesclrscrafterexit:
; If the page we jump to when done equals the page
; of the warmstart vector we'll return to BASIC so
; there's no implicit clrscr() after exit().
lda done+2
sec
sbc #>DOSWARM
ldx #>$0000
rts

View File

@@ -30,7 +30,7 @@
; - Apple II ProDOS 8 TechNote #23, ProDOS 8 Changes and Minutia
; - ProDOS TechRefMan, chapter 5.2.4
.segment "INIT"
.segment "ONCE"
initdostype:
lda $BF00
@@ -43,6 +43,6 @@ initdostype:
: sta __dos_type
done: rts
.bss
.data
__dos_type: .res 1
__dos_type: .byte $00

View File

@@ -230,14 +230,13 @@ source: jsr $BF00
; Check for startup filename support
; ProDOS TechRefMan, chapter 5.1.5.1:
; "$2000 is a jump instruction. $2003 and $2004 are $EE."
system: lda $2000
cmp #$4C
system: lda #$4C
cmp $2000
bne jump
lda $2003
cmp #$EE
lda #$EE
cmp $2003
bne jump
lda $2004
cmp #$EE
cmp $2004
bne jump
; Store cmdline in startup filename buffer

View File

@@ -6,11 +6,11 @@
;
.export __EXEHDR__ : absolute = 1 ; Linker referenced
.import __LOADADDR__, __LOADSIZE__ ; Linker generated
.import __MAIN_START__, __MAIN_LAST__ ; Linker generated
; ------------------------------------------------------------------------
.segment "EXEHDR"
.addr __LOADADDR__ ; Load address
.word __LOADSIZE__ ; Load length
.addr __MAIN_START__ ; Load address
.word __MAIN_LAST__ - __MAIN_START__ ; Load length

View File

@@ -14,7 +14,7 @@
.include "errno.inc"
.include "../filedes.inc"
.segment "INIT"
.segment "ONCE"
initiobuf:
; Convert end address highbyte to table index
@@ -90,6 +90,6 @@ iobuf_free:
; ------------------------------------------------------------------------
.bss
.data
table: .res MAX_FDS

View File

@@ -10,7 +10,7 @@
; Identify machine according to:
; Apple II Miscellaneous TechNote #7, Apple II Family Identification
.segment "INIT"
.segment "ONCE"
initostype:
sec
@@ -65,6 +65,6 @@ _get_ostype:
ldx #$00
rts
.bss
.segment "INIT"
ostype: .res 1

View File

@@ -5,11 +5,14 @@
; void __fastcall__ gotox (unsigned char x);
;
.export _gotoxy, _gotox
.export gotoxy, _gotoxy, _gotox
.import popa, VTABZ
.include "apple2.inc"
gotoxy:
jsr popa ; Get Y
_gotoxy:
clc
adc WNDTOP

View File

@@ -9,7 +9,9 @@
.include "apple2.inc"
.segment "INIT"
.macpack apple2
.segment "ONCE"
initirq:
; Check for ProDOS
@@ -36,17 +38,9 @@ prterr: ldx #msglen-1
jmp _exit
errmsg: .ifdef __APPLE2ENH__
.byte $8D, 't'|$80, 'p'|$80, 'u'|$80, 'r'|$80, 'r'|$80
.byte 'e'|$80, 't'|$80, 'n'|$80, 'i'|$80, ' '|$80, 'c'|$80
.byte 'o'|$80, 'l'|$80, 'l'|$80, 'a'|$80, ' '|$80, 'o'|$80
.byte 't'|$80, ' '|$80, 'd'|$80, 'e'|$80, 'l'|$80, 'i'|$80
.byte 'a'|$80, 'F'|$80, $8D
scrcode $0D, "tpurretni colla ot deliaF", $0D
.else
.byte $8D, 'T'|$80, 'P'|$80, 'U'|$80, 'R'|$80, 'R'|$80
.byte 'E'|$80, 'T'|$80, 'N'|$80, 'I'|$80, ' '|$80, 'C'|$80
.byte 'O'|$80, 'L'|$80, 'L'|$80, 'A'|$80, ' '|$80, 'O'|$80
.byte 'T'|$80, ' '|$80, 'D'|$80, 'E'|$80, 'L'|$80, 'I'|$80
.byte 'A'|$80, 'F'|$80, $8D
scrcode $0D, "TPURRETNI COLLA OT DELIAF", $0D
.endif
msglen = * - errmsg

View File

@@ -46,10 +46,10 @@ FNAM_LEN = $280
FNAM = $281
REM = $B2 ; BASIC token-code
; Get possible command-line arguments. Goes into the special INIT segment,
; Get possible command-line arguments. Goes into the special ONCE segment,
; which may be reused after the startup code is run.
.segment "INIT"
.segment "ONCE"
initmainargs:
@@ -83,6 +83,7 @@ initmainargs:
; destroyed.
ldy #$00
sty buffer + BUF_LEN - 1
: lda BASIC_BUF,x
sta buffer,y
inx
@@ -166,14 +167,13 @@ done: lda #<argv
stx __argv+1
rts
; This array is zeroed before initmainargs is called.
; char* argv[MAXARGS+1] = {FNAM};
.data
; char* argv[MAXARGS+1] = {FNAM};
argv: .addr FNAM
.res MAXARGS * 2
.bss
.segment "INIT"
buffer: .res BUF_LEN

View File

@@ -19,7 +19,7 @@
.include "mli.inc"
.include "filedes.inc"
.segment "INIT"
.segment "ONCE"
raisefilelevel:
; Raise file level

View File

@@ -45,7 +45,7 @@ ErrTab: .byte $01, ENOSYS ; Bad system call number
.byte $47, EEXIST ; Duplicate filename
.byte $48, ENOSPC ; Volume full
.byte $49, ENOSPC ; Volume directory full
; .byte $4A, EUNKNOWN ; Incompatible file format
.byte $4A, ENOEXEC ; Incompatible file format
.byte $4B, EINVAL ; Unsupported storage_type
; .byte $4C, EUNKNOWN ; End of file encountered
.byte $4D, ESPIPE ; Position out of range

View File

@@ -16,7 +16,7 @@
.include "filedes.inc"
.include "apple2.inc"
.segment "INIT"
.segment "ONCE"
initprompt:
; Set prompt <> ']' to let DOS 3.3 know that we're

View File

@@ -10,7 +10,7 @@
_rebootafterexit := return
.segment "INIT"
.segment "ONCE"
initreboot:
; Quit to PWRUP

View File

@@ -3,7 +3,7 @@ DEPS += ../libwrk/$(TARGET)/loader.d
../libwrk/$(TARGET)/loader.o: $(SRCDIR)/targetutil/loader.s | ../libwrk/$(TARGET)
$(ASSEMBLE_recipe)
../targetutil/loader.system: ../libwrk/$(TARGET)/loader.o $(SRCDIR)/targetutil/loader.cfg | ../targetutil
../target/$(TARGET)/util/loader.system: ../libwrk/$(TARGET)/loader.o $(SRCDIR)/targetutil/loader.cfg | ../target/$(TARGET)/util
$(LD65) -o $@ -C $(filter %.cfg,$^) $(filter-out %.cfg,$^)
$(TARGET): ../targetutil/loader.system
$(TARGET): ../target/$(TARGET)/util/loader.system

View File

@@ -16,10 +16,10 @@
.include "zeropage.inc"
.include "apple2.inc"
WIDTH = tmp2
HEIGHT = tmp3
XORIGIN = tmp4
YORIGIN = ptr1
WIDTH = ptr1
HEIGHT = ptr1+1
XORIGIN = ptr2
YORIGIN = ptr2+1
_textframexy:
sec

View File

@@ -13,7 +13,7 @@
.import start
.export _cas_init
.segment "INIT"
.segment "ONCE"
_cas_init:
.ifdef DEBUG

View File

@@ -6,13 +6,12 @@
;
.export _cclearxy, _cclear
.import popa, _gotoxy, cputdirect
.import gotoxy, cputdirect
.importzp tmp1
_cclearxy:
pha ; Save the length
jsr popa ; Get y
jsr _gotoxy ; Call this one, will pop params
jsr gotoxy ; Call this one, will pop params
pla ; Restore the length and run into _cclear
_cclear:

View File

@@ -6,7 +6,7 @@
;
.export _chlinexy, _chline
.import popa, _gotoxy, cputdirect, setcursor
.import gotoxy, cputdirect, setcursor
.importzp tmp1
.ifdef __ATARI5200__
@@ -17,8 +17,7 @@ CHRCODE = $12+64
_chlinexy:
pha ; Save the length
jsr popa ; Get y
jsr _gotoxy ; Call this one, will pop params
jsr gotoxy ; Call this one, will pop params
pla ; Restore the length
_chline:

View File

@@ -7,7 +7,7 @@
.export _cputcxy, _cputc
.export plot, cputdirect, putchar
.import popa, _gotoxy, mul40
.import gotoxy, mul40
.importzp tmp4,ptr4
.import _revflag,setcursor
@@ -15,8 +15,7 @@
_cputcxy:
pha ; Save C
jsr popa ; Get Y
jsr _gotoxy ; Set cursor, drop x
jsr gotoxy ; Set cursor, drop x and y
pla ; Restore C
_cputc:

View File

@@ -9,12 +9,12 @@
;
.export __STARTUP__ : absolute = 1 ; Mark as startup
.export _exit, start
.export _exit, start, excexit, SP_save
.import initlib, donelib
.import callmain, zerobss
.import __RESERVED_MEMORY__
.import __RAM_START__, __RAM_SIZE__
.import __MAIN_START__, __MAIN_SIZE__
.ifdef __ATARIXL__
.import __STACKSIZE__
.import sram_init
@@ -55,19 +55,19 @@ start:
.ifdef __ATARIXL__
lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
sta sp
lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
sta sp+1
stx sp+1
.else
; Report the memory usage.
lda APPMHI
ldx APPMHI+1
sta APPMHI_save ; remember old APPMHI value
lda APPMHI+1
sta APPMHI_save+1
stx APPMHI_save+1
sec
lda MEMTOP
@@ -109,12 +109,12 @@ start:
; Call the module destructors. This is also the exit() entry.
_exit: jsr donelib ; Run module destructors
_exit: ldx SP_save
txs ; Restore stack pointer
; Restore the system stuff.
ldx SP_save
txs ; Restore stack pointer
excexit:jsr donelib ; Run module destructors; 'excexit' is called from the exec routine
; Restore the left margin.
@@ -129,9 +129,9 @@ _exit: jsr donelib ; Run module destructors
; Restore APPMHI.
lda APPMHI_save
ldx APPMHI_save+1
sta APPMHI
lda APPMHI_save+1
sta APPMHI+1
stx APPMHI+1
.ifdef __ATARIXL__
@@ -142,9 +142,9 @@ _exit: jsr donelib ; Run module destructors
lda RAMTOP_save
sta RAMTOP
lda MEMTOP_save
ldx MEMTOP_save+1
sta MEMTOP
lda MEMTOP_save+1
sta MEMTOP+1
stx MEMTOP+1
; Issue a GRAPHICS 0 call (copied'n'pasted from the TGI drivers), in

View File

@@ -7,7 +7,7 @@
.include "atari.inc"
.export _cvlinexy, _cvline
.import popa, _gotoxy, putchar, setcursor
.import gotoxy, putchar, setcursor
.importzp tmp1
.ifdef __ATARI5200__
@@ -18,8 +18,7 @@ CHRCODE = $7C ; Vertical bar
_cvlinexy:
pha ; Save the length
jsr popa ; Get y
jsr _gotoxy ; Call this one, will pop params
jsr gotoxy ; Call this one, will pop params
pla ; Restore the length and run into _cvline
_cvline:

20
libsrc/atari/doesclrscr.s Normal file
View File

@@ -0,0 +1,20 @@
;
; Christian Groessler, June-2016
;
; unsigned char doesclrscr(void);
;
; returns 0/1 if after program termination the screen isn't/is cleared
;
.export _doesclrscrafterexit
.import __is_cmdline_dos
.import return1
.ifdef __ATARIXL__
_doesclrscrafterexit = return1 ; the c65 runtime always clears the screen at program termination
.else
_doesclrscrafterexit:
jsr __is_cmdline_dos ; currently (unless a DOS behaving differently is popping up)
eor #$01 ; we can get by with the inverse of __is_cmdline_dos
rts
.endif

View File

@@ -11,7 +11,7 @@
; ------------------------------------------------------------------------
; DOS type detection
.segment "INIT"
.segment "ONCE"
detect: lda DOS
cmp #'S' ; SpartaDOS
@@ -48,6 +48,6 @@ done: rts
; ------------------------------------------------------------------------
; Data
.bss
.data
__dos_type: .res 1 ; default to ATARIDOS
__dos_type: .byte ATARIDOS; default to ATARIDOS

211
libsrc/atari/exec.s Normal file
View File

@@ -0,0 +1,211 @@
;
; Christian Groessler, 12-Jun-2016
;
; int __fastcall__ exec (const char* progname, const char* cmdline);
;
; supports only XDOS at the moment
.export _exec
.import popax
.import __dos_type
.import findfreeiocb
.import incsp2
.import excexit ; from crt0.s
.import SP_save ; from crt0.s
.ifdef UCASE_FILENAME
.import ucase_fn
.import addysp
.endif
.include "zeropage.inc"
.include "errno.inc"
.include "atari.inc"
; area $0100 to $0128 might be in use (e.g. Hias' high speed patch)
CMDLINE_BUFFER = $0129 ; put progname + cmdline as one single string there
; alternatively:
;CMDLINE_BUFFER = $0480 ; put progname + cmdline as one single string there
CMDLINE_MAX = 40+3 ; max. length of drive + progname + cmdline
.code
notsupp:lda #ENOSYS ; "unsupported system call"
.byte $2C ; bit opcode, eats the next 2 bytes
noiocb: lda #EMFILE ; "too many open files"
jsr incsp2 ; clean up stack
seterr: jmp __directerrno
; entry point
_exec:
; save cmdline
sta ptr3
stx ptr3+1
ldy __dos_type
cpy #XDOS
bne notsupp
jsr findfreeiocb
bne noiocb
stx tmp4 ; remember IOCB index
; get program name
jsr popax
.ifdef UCASE_FILENAME
.ifdef DEFAULT_DEVICE
ldy #$80
.else
ldy #$00
.endif
sty tmp2 ; set flag for ucase_fn
jsr ucase_fn
bcc ucok1
invret: lda #EINVAL ; file name is too long
bne seterr
ucok1:
.endif ; defined UCASE_FILENAME
; copy program name and arguments to CMDLINE_BUFFER
sta ptr4 ; ptr4: pointer to program name
stx ptr4+1
ldy #0
; TODO: check stack ptr and and use min(CMDLINE_MAX,available_stack)
copyp: lda (ptr4),y
beq copypd
sta CMDLINE_BUFFER,y
iny
cpy #CMDLINE_MAX
bne copyp
; programe name too long
beq invret
.ifndef UCASE_FILENAME
invret: lda #EINVAL
bne seterr
.endif
; file name copied, check for args
copypd: tya ; put Y into X (index into CMDLINE_BUFFER)
tax
lda ptr3
ora ptr3+1 ; do we have arguments?
beq copycd ; no
ldy #0
lda (ptr3),y ; get first byte of cmdline parameter
beq copycd ; nothing there...
lda #' ' ; add a space btw. progname and cmdline
bne copyc1
; copy args
copyc: lda (ptr3),y
beq copycd
iny
copyc1: sta CMDLINE_BUFFER,x
inx
cpx #CMDLINE_MAX
bne copyc
; progname + arguments too long
beq invret
invexe: jsr close
lda #XNTBIN
bne setmerr
copycd: lda #ATEOL
sta CMDLINE_BUFFER,x
; open the program file, read the first two bytes and compare them to $FF
ldx tmp4 ; get IOCB index
lda ptr4 ; ptr4 points to progname
sta ICBAL,x
lda ptr4+1
sta ICBAH,x
lda #OPNIN ; open for input
sta ICAX1,x
lda #OPEN
sta ICCOM,x
jsr CIOV
tya
.ifdef UCASE_FILENAME
ldy tmp3 ; get size
jsr addysp ; free used space on the stack
; the following 'bpl' depends on 'addysp' restoring A as last command before 'rts'
.endif ; defined UCASE_FILENAME
bpl openok
pha ; remember error code
jsr close ; close the IOCB (required even if open failed)
pla ; put error code back into A
setmerr:jmp __mappederrno ; update errno from OS specific error code in A
openok: lda #>buf
sta ICBAH,x ; set buffer address
lda #<buf
sta ICBAL,x
lda #0 ; set buffer length
sta ICBLH,x
lda #2
sta ICBLL,x
lda #GETCHR ; iocb command code
sta ICCOM,x
jsr CIOV ; read it
bmi invexe ; read operation failed, return error
lda ICBLL,x ; # of bytes read
cmp #2
bne invexe
lda #$FF ; check file format (need $FFFF at the beginning)
cmp buf
bne invexe
cmp buf+1
bne invexe
jsr close ; close program file
; program file appears to be available and good
; here's the point of no return
ldx SP_save
txs ; reset stack pointer to what it was at program entry
lda tmp4 ; get IOCB index
pha ; and save it ('excexit' calls destructors and they might destroy tmp4)
jsr excexit ; on atarixl this will enable the ROM again, making all high variables inaccessible
pla
tax ; IOCB index in X
lda #<CMDLINE_BUFFER
sta ICBAL,x ; address
lda #>CMDLINE_BUFFER
sta ICBAH,x
lda #0
sta ICBLL,x ; length shouldn't be random, but 0 is ok
sta ICBLH,x
sta ICAX1,x
sta ICAX2,x
lda #80 ; XDOS: run DUP command
sta ICCOM,x
jmp CIOV_org ; no way to display an error message in case of failure, and we will return to DOS
; close IOCB, index in X
.proc close
lda #CLOSE
sta ICCOM,x
jmp CIOV ; close IOCB
.endproc
.bss
buf: .res 2

View File

@@ -1,11 +1,11 @@
; This file defines the EXE header and main chunk load header for Atari executables
.export __EXEHDR__: absolute = 1
.import __RAM_START__, __BSS_LOAD__
.import __MAIN_START__, __BSS_LOAD__
.segment "EXEHDR"
.word $FFFF
.segment "MAINHDR"
.word __RAM_START__
.word __MAIN_START__
.word __BSS_LOAD__ - 1

View File

@@ -7,6 +7,8 @@
; startup code but is nevertheless included in the compiled program when
; needed.
; XDOS support added 05/2016 by Christian Groessler
MAXARGS = 16 ; max. amount of arguments in arg. table
CL_SIZE = 64 ; command line buffer size
SPACE = 32 ; SPACE char.
@@ -20,30 +22,32 @@ SPACE = 32 ; SPACE char.
; --------------------------------------------------------------------------
; Get command line
.segment "INIT"
.segment "ONCE"
nargdos:rts
initmainargs:
lda #0
sta __argc
sta __argc+1
sta __argv
sta __argv+1
lda __dos_type ; which DOS?
cmp #ATARIDOS
beq nargdos ; DOS does not support arguments
cmp #MYDOS
bne argdos ; DOS supports arguments
nargdos:rts
cmp #MAX_DOS_WITH_CMDLINE + 1
bcs nargdos
; Initialize ourcl buffer
argdos: lda #ATEOL
sta ourcl+CL_SIZE
argdos: ldy #ATEOL
sty ourcl+CL_SIZE
; Move SpartaDOS command line to our own buffer
; Move SpartaDOS/XDOS command line to our own buffer
lda DOSVEC
cmp #XDOS
bne sparta
lda #<XLINE
sta ptr1
lda #>XLINE
sta ptr1+1
bne cpcl0
sparta: lda DOSVEC
clc
adc #<LBUF
sta ptr1
@@ -51,7 +55,7 @@ argdos: lda #ATEOL
adc #>LBUF
sta ptr1+1
ldy #0
cpcl0: ldy #0
cpcl: lda (ptr1),y
sta ourcl,y
iny
@@ -120,7 +124,7 @@ eopar:
finargs:
lda __argc
asl
asl
tax
lda #0
sta argv,x
@@ -134,7 +138,7 @@ finargs:
; --------------------------------------------------------------------------
; Data
.bss
.segment "INIT"
argv: .res (1 + MAXARGS) * 2

View File

@@ -27,10 +27,10 @@
__getdefdev:
lda __dos_type ; which DOS?
cmp #ATARIDOS
beq finish
cmp #MYDOS
beq finish
cmp #XDOS
beq xdos ; only supported on XDOS ...
; cmp #OSADOS+1 ; (redundant: #OSADOS+1 = #XDOS)
bcs finish ; ... and on OS/A+ and SpartaDOS
ldy #BUFOFF
lda #0
@@ -60,7 +60,7 @@ __getdefdev:
lda (DOSVEC),y
sta crvec+2
crvec: jsr $FFFF ; will be set to crunch vector
jsr crvec
; Get default device
@@ -69,7 +69,7 @@ crvec: jsr $FFFF ; will be set to crunch vector
sta __defdev
iny
lda (DOSVEC),y
sta __defdev+1
done: sta __defdev+1
; Return pointer to default device
@@ -77,9 +77,33 @@ finish: lda #<__defdev
ldx #>__defdev
rts
; XDOS default device retrieval
xdos:
; check XDOS version (we need >= 2.4)
lda XGLIN
cmp #$4C ; there needs to be a 'JMP' opcode here
bne finish ; older version, use DEFAULT_DEVICE or D1:
lda XVER ; get BCD encoded version ($24 for 2.4)
cmp #$24
bcc finish ; too old, below 2.4
; good XDOS version, get default drive
lda #ATEOL
sta XLINE ; simulate empty command line
ldy #0
jsr XMOVE ; create an FMS filename (which in this case only contains the drive)
lda XFILE+1
bne done
.data
; Default device
crvec: jmp $FFFF ; target address will be set to crunch vector
; Default device string
__defdev:
.ifdef DEFAULT_DEVICE
@@ -87,4 +111,3 @@ __defdev:
.else
.byte "D1:", 0
.endif

View File

@@ -6,14 +6,17 @@
.include "atari.inc"
.export _gotoxy
.export gotoxy, _gotoxy
.import popa
.import setcursor
gotoxy:
jsr popa ; Get Y
_gotoxy: ; Set the cursor position
sta ROWCRS ; Set Y
jsr popa ; Get X
sta COLCRS ; Set X
lda #0
sta COLCRS+1 ;
sta COLCRS+1
jmp setcursor

View File

@@ -13,7 +13,7 @@
; ------------------------------------------------------------------------
.segment "INIT"
.segment "ONCE"
initirq:
lda VVBLKD

View File

@@ -0,0 +1,18 @@
;
; Christian Groessler, May-2016
;
; unsigned char _is_cmdline_dos(void);
;
; returns 0 for non-commandline DOS, 1 for commandline DOS
;
.export __is_cmdline_dos
.import __dos_type
.include "atari.inc"
__is_cmdline_dos:
lda #MAX_DOS_WITH_CMDLINE
cmp __dos_type
lda #0
rol a
rts

View File

@@ -180,7 +180,7 @@ update_colors:
; ------------------------------------------------------------------------
.segment "INIT"
.segment "ONCE"
pm_init:
lda #0

View File

@@ -8,6 +8,7 @@
.include "fcntl.inc"
.include "errno.inc"
.include "fd.inc"
.include "zeropage.inc"
.export _open
.destructor closeallfiles, 5
@@ -19,9 +20,7 @@
.import incsp4
.import ldaxysp,addysp
.import __oserror
.importzp tmp4,tmp2
.ifdef UCASE_FILENAME
.importzp tmp3
.import ucase_fn
.endif
@@ -93,8 +92,10 @@ cont: ldy #3
.ifdef UCASE_FILENAME
.ifdef DEFAULT_DEVICE
ldy #$80
sty tmp2 ; set flag for ucase_fn
.else
ldy #$00
.endif
sty tmp2 ; set flag for ucase_fn
jsr ucase_fn
bcc ucok1
invret: lda #<EINVAL ; file name is too long

View File

@@ -95,7 +95,7 @@ maptable:
.byte EUNKNOWN ; 177 - haven't found documentation
.byte EUNKNOWN ; 178 - haven't found documentation
.byte EUNKNOWN ; 179 - haven't found documentation
.byte EUNKNOWN ; 180 - not a binary file
.byte ENOEXEC ; 180 - not a binary file
.byte EUNKNOWN ; 181 - [MYDOS] invalid address range
.byte EUNKNOWN ; 182 - [XDOS] invalid parameter

View File

@@ -22,11 +22,12 @@ SHRAM_HANDLERS = 1
.export CIO_handler
.export SIO_handler
.export SETVBV_handler
.export XMOVE_handler
BUFSZ = 128 ; bounce buffer size
BUFSZ_SIO = 256
.segment "INIT"
.segment "ONCE"
; Turn off ROMs, install system and interrupt wrappers, set new chargen pointer
@@ -1085,6 +1086,24 @@ SETVBV_handler:
plp
rts
;---------------------------------------------------------
XMOVE_handler:
pha
lda PORTB
sta cur_XMOVE_PORTB
enable_rom
pla
jsr XMOVE_org
php
pha
disable_rom_val cur_XMOVE_PORTB
pla
plp
rts
CIO_a: .res 1
CIO_x: .res 1
CIO_y: .res 1
@@ -1093,6 +1112,7 @@ cur_CIOV_PORTB: .res 1
cur_SIOV_PORTB: .res 1
cur_KEYBDV_PORTB: .res 1
cur_SETVBV_PORTB: .res 1
cur_XMOVE_PORTB: .res 1
orig_ptr: .res 2
orig_len: .res 2
req_len: .res 2

View File

@@ -26,11 +26,12 @@
pha
lda __dos_type
beq not_impl ; AtariDOS
cmp #OSADOS+1
bcc do_sparta ; OS/A and SpartaDOS
cmp #MYDOS
bne not_impl ; neither MyDOS, OS/A, nor SpartaDOS
pla
jmp __sysremove ; MyDOS and others (TODO: check XDOS)
jmp __sysremove ; MyDOS
not_impl:
pla

View File

@@ -3,7 +3,7 @@ DEPS += ../libwrk/$(TARGET)/w2cas.d
../libwrk/$(TARGET)/w2cas.o: $(SRCDIR)/targetutil/w2cas.c | ../libwrk/$(TARGET)
$(COMPILE_recipe)
../targetutil/w2cas.com: ../libwrk/$(TARGET)/w2cas.o ../lib/$(TARGET).lib | ../targetutil
../target/$(TARGET)/util/w2cas.com: ../libwrk/$(TARGET)/w2cas.o ../lib/$(TARGET).lib | ../target/$(TARGET)/util
$(LD65) -o $@ -t $(TARGET) $^
$(TARGET): ../targetutil/w2cas.com
$(TARGET): ../target/$(TARGET)/util/w2cas.com

View File

@@ -14,6 +14,7 @@
#include <errno.h>
#include <6502.h>
#include <atari.h>
#include <cc65.h>
#include <conio.h>
static int verbose = 1;
@@ -43,10 +44,12 @@ int main(int argc, char **argv)
struct __iocb *iocb = findfreeiocb();
int iocb_num;
/* if DOS will automatically clear the screen after the program exits, wait for a keypress... */
if (doesclrscrafterexit())
atexit((void (*)(void))cgetc);
if (! iocb) {
fprintf(stderr, "couldn't find a free iocb\n");
if (_dos_type != 1)
cgetc();
return 1;
}
iocb_num = (iocb - &IOCB) * 16;
@@ -57,10 +60,16 @@ int main(int argc, char **argv)
printf("\nfilename: ");
x = fgets(buf, 19, stdin);
printf("\n");
if (! x)
if (! x) {
printf("empty filename, exiting...\n");
return 1;
}
if (*x && *(x + strlen(x) - 1) == '\n')
*(x + strlen(x) - 1) = 0;
if (! strlen(x)) { /* empty filename */
printf("empty filename, exiting...\n");
return 1;
}
filename = x;
}
else {
@@ -74,8 +83,6 @@ int main(int argc, char **argv)
buffer = malloc(buflen);
if (! buffer) {
fprintf(stderr, "cannot alloc %ld bytes -- aborting...\n", (long)buflen);
if (_dos_type != 1)
cgetc();
return 1;
}
}
@@ -87,8 +94,6 @@ int main(int argc, char **argv)
if (! file) {
free(buffer);
fprintf(stderr, "cannot open '%s': %s\n", filename, strerror(errno));
if (_dos_type != 1)
cgetc();
return 1;
}
@@ -101,8 +106,6 @@ int main(int argc, char **argv)
file_err:
fclose(file);
free(buffer);
if (_dos_type != 1)
cgetc();
return 1;
}
if (filen > 32767l) {
@@ -133,8 +136,6 @@ int main(int argc, char **argv)
if (regs.y != 1) {
fprintf(stderr, "CIO call to open cassette returned %d\n", regs.y);
free(buffer);
if (_dos_type != 1)
cgetc();
return 1;
}
@@ -157,8 +158,6 @@ int main(int argc, char **argv)
regs.pc = 0xe456; /* CIOV */
_sys(&regs);
if (_dos_type != 1)
cgetc();
return 1;
}
@@ -173,14 +172,10 @@ int main(int argc, char **argv)
if (regs.y != 1) {
fprintf(stderr, "CIO call to close cassette returned %d\n", regs.y);
if (_dos_type != 1)
cgetc();
return 1;
}
/* all is fine */
printf("success\n");
if (_dos_type != 1)
cgetc();
return 0;
}

View File

@@ -40,7 +40,9 @@
stx ptr4+1
.ifdef DEFAULT_DEVICE
; bit #0 of tmp2 is used as a flag whether device name is present in passed string (1 = present, 0 = not present)
lda tmp2
beq hasdev ; don't fiddle with device part
; bit #0 of tmp2 is used as an additional flag whether device name is present in passed string (1 = present, 0 = not present)
ldy #1
inc tmp2 ; initialize flag: device present
lda #':'
@@ -81,11 +83,11 @@ copy_end:
.ifdef DEFAULT_DEVICE
lda #1
bit tmp2
bit tmp2 ; is a device present in the string?
bne hasdev2 ; yes, don't prepend something
bpl hasdev2
bpl hasdev2 ; check input parameter (tmp2 != $80)
ldy #128+3 ; no, prepend "D:" (or other device)
ldy #128+3 ; no, prepend "Dn:" (__defdev)
sty tmp3 ; adjust stack size used
ldy #3
jsr subysp ; adjust stack pointer

49
libsrc/atari2600/crt0.s Normal file
View File

@@ -0,0 +1,49 @@
; Atari VCS 2600 startup code for cc65
;
; Florent Flament (contact@florentflament.com), 2017
.export _exit
.export __STARTUP__ : absolute = 1
.import __RAM_START__, __RAM_SIZE__
.import copydata
.import _main
.include "zeropage.inc"
.segment "STARTUP"
start:
; Clear decimal mode
cld
; Initialization Loop:
; * Clears Atari 2600 whole memory (128 bytes) including BSS segment
; * Clears TIA registers
; * Sets system stack pointer to $ff (i.e top of zero-page)
ldx #0
txa
clearLoop:
dex
txs
pha
bne clearLoop
; Initialize data
jsr copydata
; Initialize C stack pointer
lda #<(__RAM_START__ + __RAM_SIZE__)
ldx #>(__RAM_START__ + __RAM_SIZE__)
sta sp
stx sp+1
; Call main
jsr _main
_exit: jmp _exit
.segment "VECTORS"
.word start ; NMI
.word start ; Reset
.word start ; IRQ

162
libsrc/atari2600/ctype.s Normal file
View File

@@ -0,0 +1,162 @@
;
; Ullrich von Bassewitz, 2003-10-10
;
; Character specification table.
;
.include "ctype.inc"
; The tables are readonly, put them into the rodata segment
.rodata
; The following 256 byte wide table specifies attributes for the isxxx type
; of functions. Doing it by a table means some overhead in space, but it
; has major advantages:
;
; * It is fast. If it weren't for the slow parameter passing of cc65, one
; could even define macros for the isxxx functions (this is usually
; done on other platforms).
;
; * It is highly portable. The only unportable part is the table itself,
; all real code goes into the common library.
;
; * We save some code in the isxxx functions.
__ctype:
.byte CT_CTRL ; 0/00 ___ctrl_@___
.byte CT_CTRL ; 1/01 ___ctrl_A___
.byte CT_CTRL ; 2/02 ___ctrl_B___
.byte CT_CTRL ; 3/03 ___ctrl_C___
.byte CT_CTRL ; 4/04 ___ctrl_D___
.byte CT_CTRL ; 5/05 ___ctrl_E___
.byte CT_CTRL ; 6/06 ___ctrl_F___
.byte CT_CTRL ; 7/07 ___ctrl_G___
.byte CT_CTRL ; 8/08 ___ctrl_H___
.byte CT_CTRL | CT_OTHER_WS | CT_SPACE_TAB
; 9/09 ___ctrl_I___
.byte CT_CTRL | CT_OTHER_WS ; 10/0a ___ctrl_J___
.byte CT_CTRL | CT_OTHER_WS ; 11/0b ___ctrl_K___
.byte CT_CTRL | CT_OTHER_WS ; 12/0c ___ctrl_L___
.byte CT_CTRL | CT_OTHER_WS ; 13/0d ___ctrl_M___
.byte CT_CTRL ; 14/0e ___ctrl_N___
.byte CT_CTRL ; 15/0f ___ctrl_O___
.byte CT_CTRL ; 16/10 ___ctrl_P___
.byte CT_CTRL ; 17/11 ___ctrl_Q___
.byte CT_CTRL ; 18/12 ___ctrl_R___
.byte CT_CTRL ; 19/13 ___ctrl_S___
.byte CT_CTRL ; 20/14 ___ctrl_T___
.byte CT_CTRL ; 21/15 ___ctrl_U___
.byte CT_CTRL ; 22/16 ___ctrl_V___
.byte CT_CTRL ; 23/17 ___ctrl_W___
.byte CT_CTRL ; 24/18 ___ctrl_X___
.byte CT_CTRL ; 25/19 ___ctrl_Y___
.byte CT_CTRL ; 26/1a ___ctrl_Z___
.byte CT_CTRL ; 27/1b ___ctrl_[___
.byte CT_CTRL ; 28/1c ___ctrl_\___
.byte CT_CTRL ; 29/1d ___ctrl_]___
.byte CT_CTRL ; 30/1e ___ctrl_^___
.byte CT_CTRL ; 31/1f ___ctrl_____
.byte CT_SPACE | CT_SPACE_TAB ; 32/20 ___SPACE___
.byte CT_NONE ; 33/21 _____!_____
.byte CT_NONE ; 34/22 _____"_____
.byte CT_NONE ; 35/23 _____#_____
.byte CT_NONE ; 36/24 _____$_____
.byte CT_NONE ; 37/25 _____%_____
.byte CT_NONE ; 38/26 _____&_____
.byte CT_NONE ; 39/27 _____'_____
.byte CT_NONE ; 40/28 _____(_____
.byte CT_NONE ; 41/29 _____)_____
.byte CT_NONE ; 42/2a _____*_____
.byte CT_NONE ; 43/2b _____+_____
.byte CT_NONE ; 44/2c _____,_____
.byte CT_NONE ; 45/2d _____-_____
.byte CT_NONE ; 46/2e _____._____
.byte CT_NONE ; 47/2f _____/_____
.byte CT_DIGIT | CT_XDIGIT ; 48/30 _____0_____
.byte CT_DIGIT | CT_XDIGIT ; 49/31 _____1_____
.byte CT_DIGIT | CT_XDIGIT ; 50/32 _____2_____
.byte CT_DIGIT | CT_XDIGIT ; 51/33 _____3_____
.byte CT_DIGIT | CT_XDIGIT ; 52/34 _____4_____
.byte CT_DIGIT | CT_XDIGIT ; 53/35 _____5_____
.byte CT_DIGIT | CT_XDIGIT ; 54/36 _____6_____
.byte CT_DIGIT | CT_XDIGIT ; 55/37 _____7_____
.byte CT_DIGIT | CT_XDIGIT ; 56/38 _____8_____
.byte CT_DIGIT | CT_XDIGIT ; 57/39 _____9_____
.byte CT_NONE ; 58/3a _____:_____
.byte CT_NONE ; 59/3b _____;_____
.byte CT_NONE ; 60/3c _____<_____
.byte CT_NONE ; 61/3d _____=_____
.byte CT_NONE ; 62/3e _____>_____
.byte CT_NONE ; 63/3f _____?_____
.byte CT_NONE ; 64/40 _____@_____
.byte CT_UPPER | CT_XDIGIT ; 65/41 _____A_____
.byte CT_UPPER | CT_XDIGIT ; 66/42 _____B_____
.byte CT_UPPER | CT_XDIGIT ; 67/43 _____C_____
.byte CT_UPPER | CT_XDIGIT ; 68/44 _____D_____
.byte CT_UPPER | CT_XDIGIT ; 69/45 _____E_____
.byte CT_UPPER | CT_XDIGIT ; 70/46 _____F_____
.byte CT_UPPER ; 71/47 _____G_____
.byte CT_UPPER ; 72/48 _____H_____
.byte CT_UPPER ; 73/49 _____I_____
.byte CT_UPPER ; 74/4a _____J_____
.byte CT_UPPER ; 75/4b _____K_____
.byte CT_UPPER ; 76/4c _____L_____
.byte CT_UPPER ; 77/4d _____M_____
.byte CT_UPPER ; 78/4e _____N_____
.byte CT_UPPER ; 79/4f _____O_____
.byte CT_UPPER ; 80/50 _____P_____
.byte CT_UPPER ; 81/51 _____Q_____
.byte CT_UPPER ; 82/52 _____R_____
.byte CT_UPPER ; 83/53 _____S_____
.byte CT_UPPER ; 84/54 _____T_____
.byte CT_UPPER ; 85/55 _____U_____
.byte CT_UPPER ; 86/56 _____V_____
.byte CT_UPPER ; 87/57 _____W_____
.byte CT_UPPER ; 88/58 _____X_____
.byte CT_UPPER ; 89/59 _____Y_____
.byte CT_UPPER ; 90/5a _____Z_____
.byte CT_NONE ; 91/5b _____[_____
.byte CT_NONE ; 92/5c _____\_____
.byte CT_NONE ; 93/5d _____]_____
.byte CT_NONE ; 94/5e _____^_____
.byte CT_NONE ; 95/5f _UNDERLINE_
.byte CT_NONE ; 96/60 ___grave___
.byte CT_LOWER | CT_XDIGIT ; 97/61 _____a_____
.byte CT_LOWER | CT_XDIGIT ; 98/62 _____b_____
.byte CT_LOWER | CT_XDIGIT ; 99/63 _____c_____
.byte CT_LOWER | CT_XDIGIT ; 100/64 _____d_____
.byte CT_LOWER | CT_XDIGIT ; 101/65 _____e_____
.byte CT_LOWER | CT_XDIGIT ; 102/66 _____f_____
.byte CT_LOWER ; 103/67 _____g_____
.byte CT_LOWER ; 104/68 _____h_____
.byte CT_LOWER ; 105/69 _____i_____
.byte CT_LOWER ; 106/6a _____j_____
.byte CT_LOWER ; 107/6b _____k_____
.byte CT_LOWER ; 108/6c _____l_____
.byte CT_LOWER ; 109/6d _____m_____
.byte CT_LOWER ; 110/6e _____n_____
.byte CT_LOWER ; 111/6f _____o_____
.byte CT_LOWER ; 112/70 _____p_____
.byte CT_LOWER ; 113/71 _____q_____
.byte CT_LOWER ; 114/72 _____r_____
.byte CT_LOWER ; 115/73 _____s_____
.byte CT_LOWER ; 116/74 _____t_____
.byte CT_LOWER ; 117/75 _____u_____
.byte CT_LOWER ; 118/76 _____v_____
.byte CT_LOWER ; 119/77 _____w_____
.byte CT_LOWER ; 120/78 _____x_____
.byte CT_LOWER ; 121/79 _____y_____
.byte CT_LOWER ; 122/7a _____z_____
.byte CT_NONE ; 123/7b _____{_____
.byte CT_NONE ; 124/7c _____|_____
.byte CT_NONE ; 125/7d _____}_____
.byte CT_NONE ; 126/7e _____~_____
.byte CT_OTHER_WS ; 127/7f ____DEL____
.res 128, CT_NONE ; 128-255

View File

@@ -2,10 +2,10 @@
;
; Christian Groessler, 01-Mar-2014
.include "atari.mac"
.export __CART_NAME__: absolute = 1
.macpack atari
.segment "CARTNAME"
scrcode " cc"

View File

@@ -9,7 +9,7 @@ SCREEN_BUF = $4000 - SCREEN_BUF_SIZE
.export screen_setup_20x24
.segment "INIT"
.segment "ONCE"
screen_setup_20x24:

View File

@@ -10,7 +10,7 @@
.export _cputcxy, _cputc
.export plot, cputdirect, putchar
.import popa, _gotoxy, mul20
.import gotoxy, mul20
.importzp ptr4
.import setcursor
@@ -21,8 +21,7 @@ screen_setup = screen_setup_20x24
_cputcxy:
pha ; Save C
jsr popa ; Get Y
jsr _gotoxy ; Set cursor, drop x
jsr gotoxy ; Set cursor, drop x and y
pla ; Restore C
_cputc:

View File

@@ -27,9 +27,9 @@ start:
; Set up the stack.
lda #<(__RAM_START__ + __RAM_SIZE__ - __RESERVED_MEMORY__)
ldx #>(__RAM_START__ + __RAM_SIZE__ - __RESERVED_MEMORY__)
sta sp
lda #>(__RAM_START__ + __RAM_SIZE__ - __RESERVED_MEMORY__)
sta sp+1 ; Set argument stack ptr
stx sp+1 ; Set argument stack ptr
; Call the module constructors.

View File

@@ -6,10 +6,13 @@
.include "atari5200.inc"
.export _gotoxy
.export gotoxy, _gotoxy
.import popa
.import setcursor
gotoxy:
jsr popa ; Get Y
_gotoxy: ; Set the cursor position
sta ROWCRS_5200 ; Set Y
jsr popa ; Get X

View File

@@ -9,7 +9,7 @@
; ------------------------------------------------------------------------
.segment "INIT"
.segment "ONCE"
initirq:
lda VVBLKD

View File

@@ -1,6 +1,6 @@
;
; 2010-11-14, Ullrich von Bassewitz
; 2014-09-06, Greg King
; 2016-03-17, Greg King
;
; This module supplies a small BASIC stub program that uses CALL
; to jump to the machine-language code that follows it.
@@ -22,3 +22,13 @@
.byte $00 ; End of BASIC line
Next: .addr $0000 ; BASIC program end marker
Start:
; ------------------------------------------------------------------------
; This padding is needed by a bug in the ROM.
; (The CLOAD command starts BASIC's variables table on top of the last byte
; that was loaded [instead of at the next address].)
.segment "BASTAIL"
.byte 0

View File

@@ -15,9 +15,10 @@
;--------------------------------------------------------------------------
; Put this constructor into a segment that can be re-used by programs.
; Put this constructor into a segment whose space
; will be re-used by BSS, the heap, and the C stack.
;
.segment "INIT"
.segment "ONCE"
; Turn the capitals lock off.
@@ -43,7 +44,7 @@ restore_caps:
;--------------------------------------------------------------------------
.bss
.segment "INIT"
capsave:
.res 1

View File

@@ -55,10 +55,10 @@
.endproc
; ------------------------------------------------------------------------
; Switch the cursor off. Code goes into the INIT segment
; which may be reused after it is run.
; Switch the cursor off. Code goes into the ONCE segment,
; which will be reused after it is run.
.segment "INIT"
.segment "ONCE"
initcgetc:
lsr STATUS

View File

@@ -2,14 +2,15 @@
; Startup code for cc65 (Oric version)
;
; By Debrune J<>r<EFBFBD>me <jede@oric.org> and Ullrich von Bassewitz <uz@cc65.org>
; 2015-01-09, Greg King
; 2016-03-18, Greg King
;
.export _exit
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import initlib, donelib
.import callmain, zerobss
.import __RAM_START__, __RAM_SIZE__, __STACKSIZE__
.import __MAIN_START__, __MAIN_SIZE__
.include "zeropage.inc"
.include "atmos.inc"
@@ -19,39 +20,17 @@
.segment "STARTUP"
; Save the zero-page area that we're about to use.
ldx #zpspace-1
L1: lda sp,x
sta zpsave,x
dex
bpl L1
; Clear the BSS data.
jsr zerobss
; Currently, color isn't supported on the text screen.
; Unprotect screen columns 0 and 1 (where each line's color codes would sit).
lda STATUS
sta stsave
and #%11011111
sta STATUS
; Save some system stuff; and, set up the stack.
tsx
stx spsave ; Save system stk ptr
lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
sta sp
lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
sta sp+1 ; Set argument stack ptr
; Save space by putting some of the start-up code in a segment
; that will be re-used.
; Call the module constructors.
jsr init
jsr initlib
; Clear the BSS variables (after the constructors have been run).
jsr zerobss
; Push the command-line arguments; and, call main().
@@ -70,7 +49,7 @@ _exit: jsr donelib
; Copy back the zero-page stuff.
ldx #zpspace-1
ldx #zpspace - 1
L2: lda zpsave,x
sta sp,x
dex
@@ -81,28 +60,42 @@ L2: lda zpsave,x
rts
; ------------------------------------------------------------------------
; Put this code in a place that will be re-used by BSS, the heap,
; and the C stack.
.segment "ZPSAVE1"
.segment "ONCE"
zpsave:
; Save the zero-page area that we're about to use.
; This padding is needed by a bug in the ROM.
; (The CLOAD command starts BASIC's variables table on top of the last byte
; that was loaded [instead of at the next address].)
; This is overlaid on a buffer, so that it doesn't use extra space in RAM.
init: ldx #zpspace - 1
L1: lda sp,x
sta zpsave,x
dex
bpl L1
.byte 0
; Currently, color isn't supported on the text screen.
; Unprotect screen columns 0 and 1 (where each line's color codes would sit).
; The segments "ZPSAVE1" and "ZPSAVE2" always must be together.
; They create a single object (the zpsave buffer).
lda STATUS
sta stsave
and #%11011111
sta STATUS
.segment "ZPSAVE2"
; Set up the C stack.
.res zpspace - 1
lda #<(__MAIN_START__ + __MAIN_SIZE__)
ldx #>(__MAIN_START__ + __MAIN_SIZE__)
sta sp
stx sp+1 ; Set argument stack ptr
; Call the module constructors.
jmp initlib
; ------------------------------------------------------------------------
.bss
.segment "INIT"
spsave: .res 1
stsave: .res 1
zpsave: .res zpspace

View File

@@ -9,7 +9,7 @@
; ------------------------------------------------------------------------
.segment "INIT"
.segment "ONCE"
initirq:
lda IRQVec

View File

@@ -13,34 +13,34 @@
.macpack generic
MAXARGS = 10 ; Maximum number of arguments allowed
REM = $9d ; BASIC token-code
REM = $9D ; BASIC token-code
;---------------------------------------------------------------------------
; Get possible command-line arguments. Goes into the special INIT segment,
; which may be reused after the startup code is run
; Get possible command-line arguments. Goes into the special ONCE segment,
; which will be reused after the startup code is run.
.segment "INIT"
.segment "ONCE"
.proc initmainargs
; Assume that the program was loaded, a moment ago, by the traditional LOAD
; statement. Save the "most-recent filename" as argument #0.
; Because the buffer, that we're copying into, was zeroed out,
; we don't need to add a NUL character.
;
ldy #FNAME_LEN - 1 ; limit the length
ldy #FNAME_LEN ; Limit the length
lda #0 ; The terminating NUL character
beq L1 ; Branch always
L0: lda CFOUND_NAME,y
sta name,y
L1: sta name,y
dey
bpl L0
inc __argc ; argc always is equal to, at least, 1
; Find the "rem" token.
;
ldx #0
L2: lda BASIC_BUF,x
beq done ; no "rem", no args.
beq done ; No "rem", no args.
inx
cmp #REM
bne L2
@@ -62,7 +62,7 @@ next: lda BASIC_BUF,x
beq done ; End of line reached
inx
cmp #' ' ; Skip leading spaces
beq next ;
beq next
; Found start of next argument. We've incremented the pointer in X already, so
; it points to the second character of the argument. This is useful since we
@@ -79,7 +79,7 @@ setterm:sta term ; Set end of argument marker
txa ; Get low byte
add #<args
sta argv,y ; argv[y]= &arg
sta argv,y ; argv[y]=&arg
lda #>$0000
adc #>args
sta argv+1,y
@@ -99,7 +99,7 @@ argloop:lda BASIC_BUF,x
; A contains the terminating character. To make the argument a valid C string,
; replace the terminating character by a zero.
lda #$00
lda #0
sta args-1,x
; Check if the maximum number of command line arguments is reached. If not,
@@ -119,15 +119,16 @@ done: lda #<argv
.endproc
; These arrays are zeroed before initmainargs is called.
; char name[16+1];
; char* argv[MAXARGS+1]={name};
;
.bss
.segment "INIT"
term: .res 1
name: .res FNAME_LEN + 1
args: .res SCREEN_XSIZE * 2 - 1
.data
; This array has zeroes when initmainargs starts.
; char* argv[MAXARGS+1]={name};
argv: .addr name
.res MAXARGS * 2, $00
.res MAXARGS * 2

View File

@@ -69,7 +69,7 @@ L9: lda ptr3
;--------------------------------------------------------------------------
; initstdin: Reset the stdin console.
.segment "INIT"
.segment "ONCE"
initstdin:
ldx #<-1
@@ -79,8 +79,7 @@ initstdin:
;--------------------------------------------------------------------------
.bss
.segment "INIT"
text_count:
.res 1

View File

@@ -1,6 +1,6 @@
;
; Based on code by Debrune J<>r<EFBFBD>me <jede@oric.org>
; 2015-01-08, Greg King
; 2016-03-17, Greg King
;
; The following symbol is used by the linker config. file
@@ -8,7 +8,8 @@
.export __TAPEHDR__:abs = 1
; These symbols, also, come from the configuration file.
.import __BASHDR_LOAD__, __ZPSAVE1_LOAD__, __AUTORUN__, __PROGFLAG__
.import __AUTORUN__, __PROGFLAG__
.import __BASHEAD_START__, __MAIN_LAST__
; ------------------------------------------------------------------------
@@ -16,16 +17,16 @@
.segment "TAPEHDR"
.byte $16, $16, $16 ; Sync bytes
.byte $24 ; Beginning-of-header marker
.byte $16, $16, $16 ; Sync bytes
.byte $24 ; Beginning-of-header marker
.byte $00 ; $2B0
.byte $00 ; $2AF
.byte <__PROGFLAG__ ; $2AE Language flag ($00=BASIC, $80=machine code)
.byte <__AUTORUN__ ; $2AD Auto-run flag ($C7=run, $00=only load)
.dbyt __ZPSAVE1_LOAD__ ;$2AB Address of end of file
.dbyt __BASHDR_LOAD__ ; $2A9 Address of start of file
.byte $00 ; $2A8
.byte $00 ; $2B0
.byte $00 ; $2AF
.byte <__PROGFLAG__ ; $2AE Language flag ($00=BASIC, $80=machine code)
.byte <__AUTORUN__ ; $2AD Auto-run flag ($C7=run, $00=only load)
.dbyt __MAIN_LAST__ - 1 ; $2AB Address of end of file
.dbyt __BASHEAD_START__ ; $2A9 Address of start of file
.byte $00 ; $2A8
; File name (a maximum of 17 characters), zero-terminated
.asciiz .sprintf("%u", .time)

View File

@@ -39,18 +39,18 @@ L2: jsr KBDREAD ; Read char and return in A
;--------------------------------------------------------------------------
; Module constructor/destructor
.bss
.segment "INIT"
keyvec: .res 2
.segment "INIT"
.segment "ONCE"
initcgetc:
; Save the old vector
lda KeyStoreVec
ldx KeyStoreVec+1
sta keyvec
lda KeyStoreVec+1
sta keyvec+1
stx keyvec+1
; Set the new vector. I can only hope that this works for other C128
; versions...
@@ -68,5 +68,3 @@ SetVec: sei
stx KeyStoreVec+1
cli
rts

View File

@@ -8,7 +8,7 @@
.export _cputcxy, _cputc, cputdirect, putchar
.export newline, plot
.import popa, _gotoxy
.import gotoxy
.import PLOT
.include "c128.inc"
@@ -21,8 +21,7 @@ newline = NEWLINE
_cputcxy:
pha ; Save C
jsr popa ; Get Y
jsr _gotoxy ; Set cursor, drop x
jsr gotoxy ; Set cursor, drop x and y
pla ; Restore C
; Plot a character - also used as internal function

View File

@@ -8,7 +8,7 @@
.import zerobss
.import push0, callmain
.import RESTOR, BSOUT, CLRCH
.import __RAM_START__, __RAM_SIZE__, __STACKSIZE__
.import __MAIN_START__, __MAIN_SIZE__, __STACKSIZE__
.importzp ST
.include "zeropage.inc"
@@ -56,10 +56,10 @@ L1: lda sp,x
tsx
stx spsave ; Save the system stack pointer
lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
sta sp
lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
sta sp+1 ; Set argument stack ptr
stx sp+1 ; Set argument stack ptr
; Call the module constructors.
@@ -108,7 +108,7 @@ L2: lda zpsave,x
; ------------------------------------------------------------------------
; Data
.segment "INITBSS"
.segment "INIT"
zpsave: .res zpspace

View File

@@ -9,7 +9,7 @@
; ------------------------------------------------------------------------
.segment "INIT"
.segment "ONCE"
initirq:
lda IRQVec

View File

@@ -32,10 +32,10 @@ MAXARGS = 10 ; Maximum number of arguments allowed
REM = $8f ; BASIC token-code
NAME_LEN = 16 ; Maximum length of command-name
; Get possible command-line arguments. Goes into the special INIT segment,
; Get possible command-line arguments. Goes into the special ONCE segment,
; which may be reused after the startup code is run
.segment "INIT"
.segment "ONCE"
initmainargs:
@@ -127,7 +127,7 @@ done: lda #<argv
stx __argv + 1
rts
.segment "INITBSS"
.segment "INIT"
term: .res 1
name: .res NAME_LEN + 1

View File

@@ -29,7 +29,7 @@ VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register
; --------------------------------------------------------------------------
; Initialize the mouse sprite.
.segment "INIT"
.segment "ONCE"
initmcb:

View File

@@ -63,7 +63,7 @@ BCD2dec:tax
; Constructor that writes to the 1/10 sec register of the TOD to kick it
; into action. If this is not done, the clock hangs. We will read the register
; and write it again, ignoring a possible change in between.
.segment "INIT"
.segment "ONCE"
.proc initsystime

View File

@@ -56,7 +56,7 @@ L2: jsr KBDREAD ; Read char and return in A
.constructor initkbd
.destructor donekbd
.segment "INIT"
.segment "ONCE"
.proc initkbd
@@ -69,6 +69,9 @@ L2: jsr KBDREAD ; Read char and return in A
.endproc
fnkeys: .byte $01, $01, $01, $01, $01, $01, $01, $01
.byte 133, 137, 134, 138, 135, 139, 136, 140
.code
@@ -82,11 +85,3 @@ L2: jsr KBDREAD ; Read char and return in A
rts
.endproc
; Function key table, readonly
.rodata
fnkeys: .byte $01, $01, $01, $01, $01, $01, $01, $01
.byte 133, 137, 134, 138, 135, 139, 136, 140

View File

@@ -7,7 +7,7 @@
.export _cputcxy, _cputc, cputdirect, putchar
.export newline, plot
.import popa, _gotoxy
.import gotoxy
.import PLOT
.include "plus4.inc"
@@ -15,8 +15,7 @@
_cputcxy:
pha ; Save C
jsr popa ; Get Y
jsr _gotoxy ; Set cursor, drop x
jsr gotoxy ; Set cursor, drop x and y
pla ; Restore C
; Plot a character - also used as internal function

View File

@@ -90,7 +90,7 @@ L2: lda zpsave,x
; ------------------------------------------------------------------------
.segment "INITBSS"
.segment "INIT"
zpsave: .res zpspace

View File

@@ -1,27 +1 @@
;
; Ullrich von Bassewitz, 2002-12-03
;
; unsigned char __fastcall__ get_tv (void);
; /* Return the video mode the machine is using */
;
.include "plus4.inc"
.include "get_tv.inc"
;--------------------------------------------------------------------------
; _get_tv
.proc _get_tv
ldx #TV::PAL ; Assume PAL
bit TED_MULTI1 ; Test bit 6
bvc pal
dex ; NTSC
pal: txa
ldx #0
rts
.endproc
.include "../plus4/get_tv.s"

View File

@@ -9,7 +9,7 @@
; ------------------------------------------------------------------------
.segment "INIT"
.segment "ONCE"
initirq:
lda IRQVec

View File

@@ -32,10 +32,10 @@ MAXARGS = 10 ; Maximum number of arguments allowed
REM = $8f ; BASIC token-code
NAME_LEN = 16 ; Maximum length of command-name
; Get possible command-line arguments. Goes into the special INIT segment,
; Get possible command-line arguments. Goes into the special ONCE segment,
; which may be reused after the startup code is run
.segment "INIT"
.segment "ONCE"
initmainargs:
@@ -126,7 +126,7 @@ done: lda #<argv
stx __argv + 1
rts
.segment "INITBSS"
.segment "INIT"
term: .res 1
name: .res NAME_LEN + 1

View File

@@ -7,7 +7,7 @@
.export _cputcxy, _cputc, cputdirect, putchar
.export newline, plot
.import popa, _gotoxy
.import gotoxy
.import PLOT
.include "c64.inc"
@@ -15,8 +15,7 @@
_cputcxy:
pha ; Save C
jsr popa ; Get Y
jsr _gotoxy ; Set cursor, drop x
jsr gotoxy ; Set cursor, drop x and y
pla ; Restore C
; Plot a character - also used as internal function

View File

@@ -6,7 +6,7 @@
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import initlib, donelib
.import moveinit, zerobss, callmain
.import zerobss, callmain
.import BSOUT
.import __MAIN_START__, __MAIN_SIZE__ ; Linker generated
.import __STACKSIZE__ ; from configure file
@@ -23,11 +23,6 @@
Start:
; Switch to the second charset.
lda #14
jsr BSOUT
; Switch off the BASIC ROM.
lda $01
@@ -39,22 +34,10 @@ Start:
tsx
stx spsave ; Save the system stack ptr
; Allow some re-entrancy by skipping the next task if it already was done.
; This sometimes can let us rerun the program without reloading it.
ldx move_init
beq L0
; Move the INIT segment from where it was loaded (over the bss segments)
; into where it must be run (over the BSS segment).
jsr moveinit
dec move_init ; Set to false
; Save space by putting some of the start-up code in the INIT segment,
; Save space by putting some of the start-up code in the ONCE segment,
; which can be re-used by the BSS segment, the heap and the C stack.
L0: jsr runinit
jsr init
; Clear the BSS data.
@@ -96,9 +79,9 @@ L2: lda zpsave,x
; ------------------------------------------------------------------------
.segment "INIT"
.segment "ONCE"
runinit:
init:
; Save the zero-page locations that we need.
@@ -110,11 +93,16 @@ L1: lda sp,x
; Set up the stack.
lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
lda #<(__MAIN_START__ + __MAIN_SIZE__)
ldx #>(__MAIN_START__ + __MAIN_SIZE__)
sta sp
stx sp+1 ; Set argument stack ptr
; Switch to the second charset.
lda #14
jsr BSOUT
; Call the module constructors.
jmp initlib
@@ -123,17 +111,8 @@ L1: lda sp,x
; ------------------------------------------------------------------------
; Data
.data
; These two variables were moved out of the BSS segment, and into DATA, because
; we need to use them before INIT is moved off of BSS, and before BSS is zeroed.
.segment "INIT"
mmusave:.res 1
spsave: .res 1
move_init:
.byte 1
.segment "INITBSS"
zpsave: .res zpspace

View File

@@ -0,0 +1,21 @@
; C64 sprite addresses for the TGI mouse pointer
;
; 2017-01-13, Greg King
; In order to provide a visible mouse pointer during TGI's graphics mode,
; the object file "c64-tgimousedata.o" must be linked explicitly into
; a program file. Example:
;
; cl65 -t c64 -o program-file main-code.c subroutines.s c64-tgimousedata.o
;
; Note: Currently, a program cannot have default
; pointers for both text and graphic modes.
; The TGI graphics mode uses VIC-II's 16K bank number three.
;
; Address of the TGI bitmap's color RAM
COLORMAP := $D000
.export mcb_spritepointer := COLORMAP + $03F8
.export mcb_spritememory := COLORMAP + $0400

View File

@@ -9,7 +9,7 @@
; ------------------------------------------------------------------------
.segment "INIT"
.segment "ONCE"
initirq:
lda IRQVec

View File

@@ -32,10 +32,10 @@ MAXARGS = 10 ; Maximum number of arguments allowed
REM = $8f ; BASIC token-code
NAME_LEN = 16 ; Maximum length of command-name
; Get possible command-line arguments. Goes into the special INIT segment,
; Get possible command-line arguments. Goes into the special ONCE segment,
; which may be reused after the startup code is run
.segment "INIT"
.segment "ONCE"
initmainargs:
@@ -125,7 +125,7 @@ done: lda #<argv
stx __argv + 1
rts
.segment "INITBSS"
.segment "INIT"
term: .res 1
name: .res NAME_LEN + 1

View File

@@ -30,7 +30,7 @@ VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register
; --------------------------------------------------------------------------
; Initialize the mouse sprite.
.segment "INIT"
.segment "ONCE"
initmcb:

View File

@@ -43,7 +43,7 @@
.export soft80_charset
.segment "INIT"
.segment "ONCE"
soft80_charset:
.byte $0f,$03,$0f,$00,$0f,$07,$05,$0e
.byte $0f,$05,$0e,$0b,$0f,$0b,$0f,$0f

View File

@@ -56,7 +56,7 @@ soft80_shutdown:
sta CIA2_PRA
jmp $FF5B ; Initialize video I/O
.segment "INIT"
.segment "ONCE"
firstinit:
; copy charset to RAM under I/O
sei
@@ -146,7 +146,7 @@ soft80_bitmapyhi_data:
soft80_tables_data_end:
;-------------------------------------------------------------------------------
.segment "INITBSS"
.segment "INIT"
soft80_internal_cellcolor:
.res 1
soft80_internal_bgcolor:

View File

@@ -12,7 +12,7 @@
.export soft80_newline, soft80_plot
.export soft80_checkchar
.import popa, _gotoxy
.import gotoxy
.import soft80_kplot
.import soft80_internal_bgcolor, soft80_internal_cellcolor
@@ -25,8 +25,7 @@
soft80_cputcxy:
pha ; Save C
jsr popa ; Get Y
jsr _gotoxy ; Set cursor, drop x
jsr gotoxy ; Set cursor, drop x and y
pla ; Restore C
; Plot a character - also used as internal function

View File

@@ -60,7 +60,7 @@ soft80mono_shutdown:
sta VIC_VIDEO_ADR
rts
.segment "INIT"
.segment "ONCE"
firstinit:
; copy charset to RAM under I/O
sei
@@ -150,7 +150,7 @@ soft80_bitmapyhi_data:
soft80_tables_data_end:
;-------------------------------------------------------------------------------
.segment "INITBSS"
.segment "INIT"
soft80mono_internal_cellcolor:
.res 1
soft80mono_internal_bgcolor:

View File

@@ -11,7 +11,7 @@
.export soft80mono_cputdirect, soft80mono_putchar
.export soft80mono_newline, soft80mono_plot
.import popa, _gotoxy
.import gotoxy
.import soft80mono_kplot
.import soft80mono_internal_bgcolor, soft80mono_internal_cellcolor
@@ -24,8 +24,7 @@
soft80mono_cputcxy:
pha ; Save C
jsr popa ; Get Y
jsr _gotoxy ; Set cursor, drop x
jsr gotoxy ; Set cursor, drop x and y
pla ; Restore C
; Plot a character - also used as internal function

View File

@@ -63,7 +63,7 @@ BCD2dec:tax
; Constructor that writes to the 1/10 sec register of the TOD to kick it
; into action. If this is not done, the clock hangs. We will read the register
; and write it again, ignoring a possible change in between.
.segment "INIT"
.segment "ONCE"
.proc initsystime

View File

@@ -1,7 +1,9 @@
;
; Graphics driver for the 320x200x2 mode on the C64.
;
; Based on Stephen L. Judds GRLIB code
; Based on Stephen L. Judd's GRLIB code.
;
; 2017-01-13, Greg King
;
.include "zeropage.inc"
@@ -351,7 +353,7 @@ SETPALETTE:
@L2: sta CBASE+$0000,y
sta CBASE+$0100,y
sta CBASE+$0200,y
sta CBASE+$0300,y
sta CBASE+$02e8,y
iny
bne @L2
pla
@@ -872,7 +874,7 @@ TEXTSTYLE:
OUTTEXT:
; Calculate a pointer to the representation of the character in the
; character ROM
; character ROM
ldx #((>(CHARROM + $0800)) >> 3)
ldy #0
@@ -957,5 +959,3 @@ CALC: lda Y1
lda #00
@L9: sta INRANGE
rts

8
libsrc/cbm/c_scnkey.s Normal file
View File

@@ -0,0 +1,8 @@
;
; 2016-08-07, Greg King
;
; void cbm_k_scnkey (void);
;
.import SCNKEY
.export _cbm_k_scnkey := SCNKEY

8
libsrc/cbm/c_udtim.s Normal file
View File

@@ -0,0 +1,8 @@
;
; 2016-08-07, Greg King
;
; void cbm_k_udtim (void);
;
.import UDTIM
.export _cbm_k_udtim := UDTIM

View File

@@ -6,13 +6,12 @@
;
.export _cclearxy, _cclear
.import popa, _gotoxy, cputdirect
.import gotoxy, cputdirect
.importzp tmp1
_cclearxy:
pha ; Save the length
jsr popa ; Get y
jsr _gotoxy ; Call this one, will pop params
jsr gotoxy ; Call this one, will pop params
pla ; Restore the length and run into _cclear
_cclear:
@@ -24,7 +23,3 @@ L1: lda #$20 ; Blank - screen code
dec tmp1
bne L1
L9: rts

View File

@@ -6,13 +6,12 @@
;
.export _chlinexy, _chline
.import popa, _gotoxy, cputdirect
.import gotoxy, cputdirect
.importzp tmp1, chlinechar
_chlinexy:
pha ; Save the length
jsr popa ; Get y
jsr _gotoxy ; Call this one, will pop params
jsr gotoxy ; Call this one, will pop params
pla ; Restore the length
_chline:
@@ -24,7 +23,3 @@ L1: lda #chlinechar ; Horizontal line, screen code
dec tmp1
bne L1
L9: rts

View File

@@ -6,13 +6,12 @@
;
.export _cvlinexy, _cvline
.import popa, _gotoxy, putchar, newline
.import gotoxy, putchar, newline
.importzp tmp1, cvlinechar
_cvlinexy:
pha ; Save the length
jsr popa ; Get y
jsr _gotoxy ; Call this one, will pop params
jsr gotoxy ; Call this one, will pop params
pla ; Restore the length and run into _cvline
_cvline:
@@ -25,6 +24,3 @@ L1: lda #cvlinechar ; Vertical bar
dec tmp1
bne L1
L9: rts

View File

@@ -9,13 +9,13 @@
.importzp devnum
.segment "INITBSS"
.segment "INIT"
curunit:
.res 1
.segment "INIT"
.segment "ONCE"
.proc initcurunit

View File

@@ -4,10 +4,13 @@
; void gotoxy (unsigned char x, unsigned char y);
;
.export _gotoxy
.export gotoxy, _gotoxy
.import popa, plot
.importzp CURS_X, CURS_Y
gotoxy:
jsr popa ; Get Y
_gotoxy:
sta CURS_Y ; Set Y
jsr popa ; Get X

View File

@@ -3,7 +3,7 @@
.export _mouse_def_pointercolor
.segment "INIT"
.segment "ONCE"
_mouse_def_pointercolor:

View File

@@ -3,7 +3,7 @@
.export _mouse_def_pointershape
.segment "INIT"
.segment "ONCE"
_mouse_def_pointershape:

View File

@@ -22,7 +22,7 @@
;--------------------------------------------------------------------------
; initstdin: Open the stdin file descriptors for the keyboard
.segment "INIT"
.segment "ONCE"
.proc initstdin

View File

@@ -20,7 +20,7 @@
;--------------------------------------------------------------------------
; initstdout: Open the stdout and stderr file descriptors for the screen.
.segment "INIT"
.segment "ONCE"
.proc initstdout

View File

@@ -8,7 +8,7 @@
.export _cputcxy, _cputc, cputdirect, putchar
.export newline, plot
.import popa, _gotoxy
.import gotoxy
.import __VIDRAM_START__
.import CURS_X: zp, CURS_Y: zp, CHARCOLOR: zp, RVS: zp
.import SCREEN_PTR: zp, CRAM_PTR: zp
@@ -22,8 +22,7 @@
_cputcxy:
pha ; Save C
jsr popa ; Get Y
jsr _gotoxy ; Set cursor, drop x
jsr gotoxy ; Set cursor, drop x and y
pla ; Restore C
; Plot a character - also used as internal function

Some files were not shown because too many files have changed in this diff Show More