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:
cuz
2005-02-26 09:28:46 +00:00
parent 6ec87c5dd9
commit d0bee35728
23 changed files with 166 additions and 59 deletions

View File

@@ -49,7 +49,10 @@
.endproc .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: initcgetc:
lda STATUS lda STATUS

View File

@@ -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 .proc initmainargs

View File

@@ -40,32 +40,31 @@ L2: lda KEY_COUNT ; Check characters again
.bss .bss
keyvec: .res 2 keyvec: .res 2
.code .segment "INIT"
initcgetc: initcgetc:
; Save the old vector ; Save the old vector
lda KeyStoreVec lda KeyStoreVec
sta keyvec sta keyvec
lda KeyStoreVec+1 lda KeyStoreVec+1
sta keyvec+1 sta keyvec+1
; Set the new vector. I can only hope that this works for other C128 ; Set the new vector. I can only hope that this works for other C128
; versions... ; versions...
lda #<$C6B7 lda #<$C6B7
ldx #>$C6B7 ldx #>$C6B7
jmp SetVec
SetVec: sei
sta KeyStoreVec
stx KeyStoreVec+1
cli
rts
.code
donecgetc: donecgetc:
lda #$00
sta SCROLL
lda keyvec lda keyvec
ldx keyvec+1 ldx keyvec+1
bne SetVec SetVec: sei
sta KeyStoreVec
stx KeyStoreVec+1
cli
rts

View File

@@ -18,6 +18,9 @@
cputdirect = PRINT cputdirect = PRINT
newline = NEWLINE newline = NEWLINE
;--------------------------------------------------------------------------
.code
_cputcxy: _cputcxy:
pha ; Save C pha ; Save C
@@ -75,7 +78,8 @@ plot: ldy CURS_X
putchar = $CC2F 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: initcputc:
lda #$C0 lda #$C0

View File

@@ -3,7 +3,7 @@
; Ullrich von Bassewitz, 2003-03-07 ; Ullrich von Bassewitz, 2003-03-07
; Based on code from Stefan A. Haubenthal, <polluks@web.de> ; Based on code from Stefan A. Haubenthal, <polluks@web.de>
; 2003-05-18, Greg King ; 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. ; Scan a group of arguments that are in BASIC's input-buffer.
; Build an array that points to the beginning of each argument. ; 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 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: initmainargs:
; Assume that the program was loaded, a moment ago, by the traditional LOAD ; Assume that the program was loaded, a moment ago, by the traditional LOAD

View File

@@ -56,6 +56,8 @@ L2: jsr KBDREAD ; Read char and return in A
.constructor initkbd .constructor initkbd
.destructor donekbd .destructor donekbd
.segment "INIT"
.proc initkbd .proc initkbd
ldy #15 ldy #15
@@ -68,6 +70,8 @@ L2: jsr KBDREAD ; Read char and return in A
.endproc .endproc
.code
.proc donekbd .proc donekbd
ldx #$39 ; Copy the original function keys ldx #$39 ; Copy the original function keys

View File

@@ -3,7 +3,7 @@
; Ullrich von Bassewitz, 2003-03-07 ; Ullrich von Bassewitz, 2003-03-07
; Based on code from Stefan A. Haubenthal, <polluks@web.de> ; Based on code from Stefan A. Haubenthal, <polluks@web.de>
; 2003-05-18, Greg King ; 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. ; Scan a group of arguments that are in BASIC's input-buffer.
; Build an array that points to the beginning of each argument. ; Build an array that points to the beginning of each argument.
@@ -30,11 +30,14 @@
MAXARGS = 10 ; Maximum number of arguments allowed MAXARGS = 10 ; Maximum number of arguments allowed
REM = $8f ; BASIC token-code REM = $8f ; BASIC token-code
NAME_LEN = 16 ; maximum length of command-name 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: initmainargs:
; Assume that the program was loaded, a moment ago, by the traditional LOAD ; Assume that the program was loaded, a moment ago, by the traditional LOAD

View File

@@ -3,7 +3,7 @@
; Ullrich von Bassewitz, 2003-03-07 ; Ullrich von Bassewitz, 2003-03-07
; Based on code from Stefan A. Haubenthal, <polluks@web.de> ; Based on code from Stefan A. Haubenthal, <polluks@web.de>
; 2003-05-18, Greg King ; 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. ; Scan a group of arguments that are in BASIC's input-buffer.
; Build an array that points to the beginning of each argument. ; 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 REM = $8f ; BASIC token-code
NAME_LEN = 16 ; maximum length of command-name 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: initmainargs:
; Assume that the program was loaded, a moment ago, by the traditional LOAD ; Assume that the program was loaded, a moment ago, by the traditional LOAD

View File

@@ -21,6 +21,8 @@
;-------------------------------------------------------------------------- ;--------------------------------------------------------------------------
; initstdin: Open the stdin file descriptors for the keyboard ; initstdin: Open the stdin file descriptors for the keyboard
.segment "INIT"
.proc initstdin .proc initstdin
lda #LFN_READ lda #LFN_READ
@@ -37,6 +39,7 @@
;-------------------------------------------------------------------------- ;--------------------------------------------------------------------------
; _read ; _read
.code
.proc _read .proc _read

View File

@@ -20,6 +20,8 @@
;-------------------------------------------------------------------------- ;--------------------------------------------------------------------------
; initstdout: Open the stdout and stderr file descriptors for the screen. ; initstdout: Open the stdout and stderr file descriptors for the screen.
.segment "INIT"
.proc initstdout .proc initstdout
lda #LFN_WRITE lda #LFN_WRITE
@@ -41,6 +43,7 @@
;-------------------------------------------------------------------------- ;--------------------------------------------------------------------------
; _write ; _write
.code
.proc _write .proc _write

View File

@@ -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 .proc initmainargs

View File

@@ -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 .proc initmainargs

View File

@@ -15,7 +15,7 @@
.import _cursor .import _cursor
.constructor initscrsize .constructor initscrsize
.code .segment "INIT"
initscrsize: initscrsize:
lda graphMode lda graphMode

View File

@@ -21,6 +21,8 @@
;--------------------------------------------------------------------------- ;---------------------------------------------------------------------------
; Setup arguments for main ; Setup arguments for main
.segment "INIT"
.proc initmainargs .proc initmainargs
; Setup a pointer to our argv vector ; Setup a pointer to our argv vector

View File

@@ -45,7 +45,8 @@ CFLAGS = -Osir -g -T -t $(SYS) --forget-inc-paths -I . -I ../../include
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
# Object files # Object files
OBJS = cgetc.o \ OBJS = cartread.o \
cgetc.o \
crt0.o \ crt0.o \
ctype.o \ ctype.o \
eeprom.o \ eeprom.o \

49
libsrc/lynx/cartread.s Normal file
View 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

View File

@@ -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 .proc initmainargs

View File

@@ -19,11 +19,13 @@
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
.code
_cputcxy: _cputcxy:
pha ; Save C pha ; Save C
jsr popa ; Get Y jsr popa ; Get Y
jsr _gotoxy ; Set cursor, drop x jsr _gotoxy ; Set cursor, drop x
pla ; Restore C pla ; Restore C
; Plot a character - also used as internal function ; Plot a character - also used as internal function
@@ -67,13 +69,16 @@ plot: ldy CURS_X
; position in Y ; position in Y
putchar: putchar:
ora RVS ; Set revers bit ora RVS ; Set revers bit
ldy SCREEN_PTR+1 ldy SCREEN_PTR+1
ldx SCREEN_PTR ldx SCREEN_PTR
jmp ppubuf_put 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: conioinit:
jsr ppuinit jsr ppuinit

View File

@@ -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 .proc initmainargs

View File

@@ -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 .proc initmainargs

View File

@@ -59,7 +59,7 @@ L2: sta ENABLE_ROM ; Bank in the ROM
.constructor initkbd .constructor initkbd
.destructor donekbd .destructor donekbd
.code ; Can go into the normal code segment .segment "INIT" ; Special init code segment may get overwritten
.proc initkbd .proc initkbd

View File

@@ -3,7 +3,7 @@
; Ullrich von Bassewitz, 2003-03-07 ; Ullrich von Bassewitz, 2003-03-07
; Based on code from Stefan A. Haubenthal, <polluks@web.de> ; Based on code from Stefan A. Haubenthal, <polluks@web.de>
; 2003-05-18, Greg King ; 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. ; Scan a group of arguments that are in BASIC's input-buffer.
; Build an array that points to the beginning of each argument. ; Build an array that points to the beginning of each argument.
@@ -30,11 +30,14 @@
MAXARGS = 10 ; Maximum number of arguments allowed MAXARGS = 10 ; Maximum number of arguments allowed
REM = $8f ; BASIC token-code REM = $8f ; BASIC token-code
NAME_LEN = 16 ; maximum length of command-name 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: initmainargs:
; Assume that the program was loaded, a moment ago, by the traditional LOAD ; Assume that the program was loaded, a moment ago, by the traditional LOAD
@@ -123,6 +126,7 @@ done: lda #<argv
stx __argv + 1 stx __argv + 1
rts rts
; --------------------------------------------------------------------------
; These arrays are zeroed before initmainargs is called. ; These arrays are zeroed before initmainargs is called.
; char name[16+1]; ; char name[16+1];
; char* argv[MAXARGS+1]={name}; ; char* argv[MAXARGS+1]={name};

View File

@@ -3,7 +3,7 @@
; Ullrich von Bassewitz, 2003-03-07 ; Ullrich von Bassewitz, 2003-03-07
; Based on code from Stefan A. Haubenthal, <polluks@web.de> ; Based on code from Stefan A. Haubenthal, <polluks@web.de>
; 2003-05-18, Greg King ; 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. ; Scan a group of arguments that are in BASIC's input-buffer.
; Build an array that points to the beginning of each argument. ; 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 REM = $8f ; BASIC token-code
NAME_LEN = 16 ; maximum length of command-name 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: initmainargs:
; Assume that the program was loaded, a moment ago, by the traditional LOAD ; Assume that the program was loaded, a moment ago, by the traditional LOAD