mirror of
https://github.com/cc65/cc65.git
synced 2025-01-10 19:29:45 +00:00
Move constructor code into the INIT segment
git-svn-id: svn://svn.cc65.org/cc65/trunk@3405 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
6ec87c5dd9
commit
d0bee35728
@ -49,7 +49,10 @@
|
||||
.endproc
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Switch the cursor off, disable capslock
|
||||
; Switch the cursor off, disable capslock. Code goes into the INIT segment
|
||||
; which may be reused after it is run.
|
||||
|
||||
.segment "INIT"
|
||||
|
||||
initcgetc:
|
||||
lda STATUS
|
||||
|
@ -10,7 +10,10 @@
|
||||
|
||||
|
||||
;---------------------------------------------------------------------------
|
||||
; Setup arguments for main
|
||||
; 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
|
||||
|
||||
|
@ -40,32 +40,31 @@ L2: lda KEY_COUNT ; Check characters again
|
||||
.bss
|
||||
keyvec: .res 2
|
||||
|
||||
.code
|
||||
.segment "INIT"
|
||||
initcgetc:
|
||||
|
||||
; Save the old vector
|
||||
|
||||
lda KeyStoreVec
|
||||
sta keyvec
|
||||
lda KeyStoreVec+1
|
||||
sta keyvec+1
|
||||
lda KeyStoreVec
|
||||
sta keyvec
|
||||
lda KeyStoreVec+1
|
||||
sta keyvec+1
|
||||
|
||||
; Set the new vector. I can only hope that this works for other C128
|
||||
; versions...
|
||||
|
||||
lda #<$C6B7
|
||||
ldx #>$C6B7
|
||||
|
||||
SetVec: sei
|
||||
sta KeyStoreVec
|
||||
stx KeyStoreVec+1
|
||||
cli
|
||||
rts
|
||||
lda #<$C6B7
|
||||
ldx #>$C6B7
|
||||
jmp SetVec
|
||||
|
||||
.code
|
||||
donecgetc:
|
||||
lda #$00
|
||||
sta SCROLL
|
||||
lda keyvec
|
||||
ldx keyvec+1
|
||||
bne SetVec
|
||||
SetVec: sei
|
||||
sta KeyStoreVec
|
||||
stx KeyStoreVec+1
|
||||
cli
|
||||
rts
|
||||
|
||||
|
||||
|
@ -18,6 +18,9 @@
|
||||
cputdirect = PRINT
|
||||
newline = NEWLINE
|
||||
|
||||
;--------------------------------------------------------------------------
|
||||
|
||||
.code
|
||||
|
||||
_cputcxy:
|
||||
pha ; Save C
|
||||
@ -75,7 +78,8 @@ plot: ldy CURS_X
|
||||
putchar = $CC2F
|
||||
|
||||
;--------------------------------------------------------------------------
|
||||
; Module constructor/destructor
|
||||
; Module constructor/destructor. Don't move the constructor into the INIT
|
||||
; segment, because it shares most of the code with the destructor.
|
||||
|
||||
initcputc:
|
||||
lda #$C0
|
||||
|
@ -3,7 +3,7 @@
|
||||
; Ullrich von Bassewitz, 2003-03-07
|
||||
; Based on code from Stefan A. Haubenthal, <polluks@web.de>
|
||||
; 2003-05-18, Greg King
|
||||
; 2004-04-28, Ullrich von Bassewitz
|
||||
; 2004-04-28, 2005-02-26, Ullrich von Bassewitz
|
||||
;
|
||||
; Scan a group of arguments that are in BASIC's input-buffer.
|
||||
; Build an array that points to the beginning of each argument.
|
||||
@ -33,8 +33,11 @@ REM = $8f ; BASIC token-code
|
||||
NAME_LEN = 16 ; maximum length of command-name
|
||||
|
||||
|
||||
; Get possible command-line arguments.
|
||||
;
|
||||
; Get possible command-line arguments. Goes into the special INIT segment,
|
||||
; which may be reused after the startup code is run
|
||||
|
||||
.segment "INIT"
|
||||
|
||||
initmainargs:
|
||||
|
||||
; Assume that the program was loaded, a moment ago, by the traditional LOAD
|
||||
|
@ -56,6 +56,8 @@ L2: jsr KBDREAD ; Read char and return in A
|
||||
.constructor initkbd
|
||||
.destructor donekbd
|
||||
|
||||
.segment "INIT"
|
||||
|
||||
.proc initkbd
|
||||
|
||||
ldy #15
|
||||
@ -68,6 +70,8 @@ L2: jsr KBDREAD ; Read char and return in A
|
||||
.endproc
|
||||
|
||||
|
||||
.code
|
||||
|
||||
.proc donekbd
|
||||
|
||||
ldx #$39 ; Copy the original function keys
|
||||
|
@ -3,7 +3,7 @@
|
||||
; Ullrich von Bassewitz, 2003-03-07
|
||||
; Based on code from Stefan A. Haubenthal, <polluks@web.de>
|
||||
; 2003-05-18, Greg King
|
||||
; 2004-04-28, Ullrich von Bassewitz
|
||||
; 2004-04-28, 2005-02-26, Ullrich von Bassewitz
|
||||
;
|
||||
; Scan a group of arguments that are in BASIC's input-buffer.
|
||||
; Build an array that points to the beginning of each argument.
|
||||
@ -30,11 +30,14 @@
|
||||
|
||||
|
||||
MAXARGS = 10 ; Maximum number of arguments allowed
|
||||
REM = $8f ; BASIC token-code
|
||||
NAME_LEN = 16 ; maximum length of command-name
|
||||
REM = $8f ; BASIC token-code
|
||||
NAME_LEN = 16 ; maximum length of command-name
|
||||
|
||||
; Get possible command-line arguments. Goes into the special INIT segment,
|
||||
; which may be reused after the startup code is run
|
||||
|
||||
.segment "INIT"
|
||||
|
||||
; Get possible command-line arguments.
|
||||
;
|
||||
initmainargs:
|
||||
|
||||
; Assume that the program was loaded, a moment ago, by the traditional LOAD
|
||||
|
@ -3,7 +3,7 @@
|
||||
; Ullrich von Bassewitz, 2003-03-07
|
||||
; Based on code from Stefan A. Haubenthal, <polluks@web.de>
|
||||
; 2003-05-18, Greg King
|
||||
; 2004-04-28, Ullrich von Bassewitz
|
||||
; 2004-04-28, 2005-02-26, Ullrich von Bassewitz
|
||||
;
|
||||
; Scan a group of arguments that are in BASIC's input-buffer.
|
||||
; Build an array that points to the beginning of each argument.
|
||||
@ -33,8 +33,11 @@ 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.
|
||||
;
|
||||
; Get possible command-line arguments. Goes into the special INIT segment,
|
||||
; which may be reused after the startup code is run
|
||||
|
||||
.segment "INIT"
|
||||
|
||||
initmainargs:
|
||||
|
||||
; Assume that the program was loaded, a moment ago, by the traditional LOAD
|
||||
|
@ -20,6 +20,8 @@
|
||||
|
||||
;--------------------------------------------------------------------------
|
||||
; initstdin: Open the stdin file descriptors for the keyboard
|
||||
|
||||
.segment "INIT"
|
||||
|
||||
.proc initstdin
|
||||
|
||||
@ -37,6 +39,7 @@
|
||||
;--------------------------------------------------------------------------
|
||||
; _read
|
||||
|
||||
.code
|
||||
|
||||
.proc _read
|
||||
|
||||
|
@ -20,6 +20,8 @@
|
||||
;--------------------------------------------------------------------------
|
||||
; initstdout: Open the stdout and stderr file descriptors for the screen.
|
||||
|
||||
.segment "INIT"
|
||||
|
||||
.proc initstdout
|
||||
|
||||
lda #LFN_WRITE
|
||||
@ -40,7 +42,8 @@
|
||||
|
||||
;--------------------------------------------------------------------------
|
||||
; _write
|
||||
|
||||
|
||||
.code
|
||||
|
||||
.proc _write
|
||||
|
||||
|
@ -10,7 +10,10 @@
|
||||
|
||||
|
||||
;---------------------------------------------------------------------------
|
||||
; Setup arguments for main
|
||||
; 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
|
||||
|
||||
|
@ -10,7 +10,10 @@
|
||||
|
||||
|
||||
;---------------------------------------------------------------------------
|
||||
; Setup arguments for main
|
||||
; 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
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
;
|
||||
; 6.3.2001, 17.4.2003
|
||||
|
||||
|
||||
|
||||
.include "../inc/geossym.inc"
|
||||
|
||||
.export xsize, ysize
|
||||
@ -14,8 +14,8 @@
|
||||
.importzp cursor_r, cursor_c
|
||||
.import _cursor
|
||||
.constructor initscrsize
|
||||
|
||||
.code
|
||||
|
||||
.segment "INIT"
|
||||
|
||||
initscrsize:
|
||||
lda graphMode
|
||||
|
@ -21,6 +21,8 @@
|
||||
;---------------------------------------------------------------------------
|
||||
; Setup arguments for main
|
||||
|
||||
.segment "INIT"
|
||||
|
||||
.proc initmainargs
|
||||
|
||||
; Setup a pointer to our argv vector
|
||||
|
@ -45,7 +45,8 @@ CFLAGS = -Osir -g -T -t $(SYS) --forget-inc-paths -I . -I ../../include
|
||||
#--------------------------------------------------------------------------
|
||||
# Object files
|
||||
|
||||
OBJS = cgetc.o \
|
||||
OBJS = cartread.o \
|
||||
cgetc.o \
|
||||
crt0.o \
|
||||
ctype.o \
|
||||
eeprom.o \
|
||||
|
49
libsrc/lynx/cartread.s
Normal file
49
libsrc/lynx/cartread.s
Normal file
@ -0,0 +1,49 @@
|
||||
; ***
|
||||
; CC65 Lynx Library
|
||||
;
|
||||
; Originally by Bastian Schick
|
||||
; http://www.geocities.com/SiliconValley/Byte/4242/lynx/
|
||||
;
|
||||
; Ported to cc65 (http://www.cc65.org) by
|
||||
; Shawn Jefferson, June 2004
|
||||
;
|
||||
; ***
|
||||
;
|
||||
; void __fastcall__ read_cart_block(unsigned char block, char *dest)
|
||||
;
|
||||
; Reads an entire block (1024 bytes) from the cartridge into the buffer
|
||||
; pointed to by dest.
|
||||
|
||||
|
||||
.export _read_cart_block
|
||||
.import FileSelectBlock, FileReadBytes
|
||||
.import popa
|
||||
|
||||
.include "extzp.inc"
|
||||
|
||||
|
||||
.code
|
||||
|
||||
;*******************************************
|
||||
; void read_cart_block (unsigned char block, char *dest);
|
||||
; loads one Block (1024 bytes) to pDest
|
||||
|
||||
_read_cart_block:
|
||||
sta _FileDestPtr ; lo
|
||||
stx _FileDestPtr+1 ; hi
|
||||
|
||||
jsr popa ; bBlock
|
||||
|
||||
sta _FileCurrBlock
|
||||
jsr FileSelectBlock ; select block# (Accu)
|
||||
|
||||
lda #<1024 ; load a whole block (1024 bytes)
|
||||
eor #$ff
|
||||
tax
|
||||
lda #>1024
|
||||
eor #$ff
|
||||
tay
|
||||
|
||||
jmp FileReadBytes
|
||||
|
||||
|
@ -10,7 +10,10 @@
|
||||
|
||||
|
||||
;---------------------------------------------------------------------------
|
||||
; Setup arguments for main
|
||||
; 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
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
;
|
||||
|
||||
.export _cputcxy, _cputc, cputdirect, putchar
|
||||
.export newline
|
||||
.export newline
|
||||
.constructor conioinit
|
||||
.import popa, _gotoxy
|
||||
.import ppuinit, paletteinit, ppubuf_put
|
||||
@ -18,12 +18,14 @@
|
||||
.include "nes.inc"
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
.code
|
||||
|
||||
_cputcxy:
|
||||
pha ; Save C
|
||||
jsr popa ; Get Y
|
||||
pha ; Save C
|
||||
jsr popa ; Get Y
|
||||
jsr _gotoxy ; Set cursor, drop x
|
||||
pla ; Restore C
|
||||
pla ; Restore C
|
||||
|
||||
; Plot a character - also used as internal function
|
||||
|
||||
@ -67,13 +69,16 @@ plot: ldy CURS_X
|
||||
; position in Y
|
||||
|
||||
putchar:
|
||||
ora RVS ; Set revers bit
|
||||
ora RVS ; Set revers bit
|
||||
ldy SCREEN_PTR+1
|
||||
ldx SCREEN_PTR
|
||||
jmp ppubuf_put
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
; Initialize the conio subsystem
|
||||
; Initialize the conio subsystem. Code goes into the INIT segment, which may
|
||||
; be reused after startup.
|
||||
|
||||
.segment "INIT"
|
||||
|
||||
conioinit:
|
||||
jsr ppuinit
|
||||
|
@ -10,7 +10,10 @@
|
||||
|
||||
|
||||
;---------------------------------------------------------------------------
|
||||
; Setup arguments for main
|
||||
; 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
|
||||
|
||||
|
@ -10,7 +10,10 @@
|
||||
|
||||
|
||||
;---------------------------------------------------------------------------
|
||||
; Setup arguments for main
|
||||
; 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
|
||||
|
||||
|
@ -59,7 +59,7 @@ L2: sta ENABLE_ROM ; Bank in the ROM
|
||||
.constructor initkbd
|
||||
.destructor donekbd
|
||||
|
||||
.code ; Can go into the normal code segment
|
||||
.segment "INIT" ; Special init code segment may get overwritten
|
||||
|
||||
.proc initkbd
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
; Ullrich von Bassewitz, 2003-03-07
|
||||
; Based on code from Stefan A. Haubenthal, <polluks@web.de>
|
||||
; 2003-05-18, Greg King
|
||||
; 2004-04-28, Ullrich von Bassewitz
|
||||
; 2004-04-28, 2005-02-26, Ullrich von Bassewitz
|
||||
;
|
||||
; Scan a group of arguments that are in BASIC's input-buffer.
|
||||
; Build an array that points to the beginning of each argument.
|
||||
@ -26,15 +26,18 @@
|
||||
.import __argc, __argv
|
||||
|
||||
.include "plus4.inc"
|
||||
|
||||
|
||||
|
||||
|
||||
MAXARGS = 10 ; Maximum number of arguments allowed
|
||||
REM = $8f ; BASIC token-code
|
||||
NAME_LEN = 16 ; maximum length of command-name
|
||||
REM = $8f ; BASIC token-code
|
||||
NAME_LEN = 16 ; maximum length of command-name
|
||||
|
||||
; Get possible command-line arguments. Goes into the special INIT segment,
|
||||
; which may be reused after the startup code is run
|
||||
|
||||
.segment "INIT"
|
||||
|
||||
; Get possible command-line arguments.
|
||||
;
|
||||
initmainargs:
|
||||
|
||||
; Assume that the program was loaded, a moment ago, by the traditional LOAD
|
||||
@ -117,12 +120,13 @@ argloop:lda BASIC_BUF,x
|
||||
|
||||
; (The last vector in argv[] already is NULL.)
|
||||
|
||||
done: lda #<argv
|
||||
done: lda #<argv
|
||||
ldx #>argv
|
||||
sta __argv
|
||||
stx __argv + 1
|
||||
rts
|
||||
|
||||
|
||||
; --------------------------------------------------------------------------
|
||||
; These arrays are zeroed before initmainargs is called.
|
||||
; char name[16+1];
|
||||
; char* argv[MAXARGS+1]={name};
|
||||
|
@ -3,7 +3,7 @@
|
||||
; Ullrich von Bassewitz, 2003-03-07
|
||||
; Based on code from Stefan A. Haubenthal, <polluks@web.de>
|
||||
; 2003-05-18, Greg King
|
||||
; 2004-04-28, Ullrich von Bassewitz
|
||||
; 2004-04-28, 2005-02-26, Ullrich von Bassewitz
|
||||
;
|
||||
; Scan a group of arguments that are in BASIC's input-buffer.
|
||||
; Build an array that points to the beginning of each argument.
|
||||
@ -33,8 +33,11 @@ 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.
|
||||
;
|
||||
; Get possible command-line arguments. Goes into the special INIT segment,
|
||||
; which may be reused after the startup code is run
|
||||
|
||||
.segment "INIT"
|
||||
|
||||
initmainargs:
|
||||
|
||||
; Assume that the program was loaded, a moment ago, by the traditional LOAD
|
||||
@ -100,7 +103,7 @@ argloop:lda BASIC_BUF,x
|
||||
inx
|
||||
cmp term
|
||||
bne argloop
|
||||
|
||||
|
||||
; We've found the end of the argument. X points one character behind it, and
|
||||
; A contains the terminating character. To make the argument a valid C string,
|
||||
; replace the terminating character by a zero.
|
||||
|
Loading…
x
Reference in New Issue
Block a user