ctype.o \
cvline.o \
kbhit.o \
+ mainargs.o \
randomize.o \
read.o \
revers.o \
.import initlib, donelib
.import zerobss, push0
.import __STARTUP_LOAD__, __BSS_LOAD__ ; Linker generated
- .import _main
+ .import callmain
.include "zeropage.inc"
.include "apple2.inc"
ldx #zpspace-1
L1: lda sp,x
- sta zpsave,x ; Save the zero page locations we need
+ sta zpsave,x ; Save the zero page locations we need
dex
bpl L1
; Save system stuff and setup the stack
tsx
- stx spsave ; Save the system stack ptr
+ stx spsave ; Save the system stack ptr
lda MEMSIZE
sta sp
lda MEMSIZE+1
- sta sp+1 ; Set argument stack ptr
+ sta sp+1 ; Set argument stack ptr
; Call module constructors
;; sta USEROM
-; Pass an empty command line
+; Push arguments and call main()
- jsr push0 ; argc
- jsr push0 ; argv
-
- ldy #4 ; Argument size
- jsr _main ; call the users code
+ jsr callmain
; Call module destructors. This is also the _exit entry.
; Restore system stuff
- lda #$ff ; Reset text mode
+ lda #$ff ; Reset text mode
sta TEXTTYP
ldx spsave
--- /dev/null
+;
+; Ullrich von Bassewitz, 2003-03-07
+;
+; Setup arguments for main
+;
+
+
+ .constructor initmainargs, 24
+ .import __argc, __argv
+
+
+;---------------------------------------------------------------------------
+; Setup arguments for main
+
+.proc initmainargs
+
+ rts
+
+.endproc
+
+
C_OBJS =
S_OBJS = crt0.o \
+ mainargs.o \
systime.o
#--------------------------------------------------------------------------
.export _exit
.import initlib, donelib
- .import push0, _main, zerobss
+ .import push0, callmain, zerobss
.import __RAM_START__, __RAM_SIZE__ ; Linker generated
.importzp sp
jsr initlib
-; Pass an empty command line
+; Push arguments and call main()
- jsr push0 ; argc
- jsr push0 ; argv
-
- ldy #4 ; Argument size
- jsr _main ; call the users code
+ jsr callmain
; Call module destructors. This is also the _exit entry.
--- /dev/null
+;
+; Ullrich von Bassewitz, 2003-03-07
+;
+; Setup arguments for main
+;
+
+
+ .constructor initmainargs, 24
+ .import __argc, __argv
+
+
+;---------------------------------------------------------------------------
+; Setup arguments for main
+
+.proc initmainargs
+
+ rts
+
+.endproc
+
+
joy_stddrv.o \
kbhit.o \
kernal.o \
+ mainargs.o \
mouse.o \
randomize.o \
revers.o \
.export _exit
.import condes, initlib, donelib
.import zerobss
- .import push0, _main
+ .import push0, callmain
.import RESTOR, BSOUT, CLRCH
.import __IRQFUNC_TABLE__, __IRQFUNC_COUNT__
.import __RAM_START__, __RAM_SIZE__
stx IRQVec+1
cli
-; Pass an empty command line
+; Push arguments and call main()
-NoIRQ1: jsr push0 ; argc
- jsr push0 ; argv
-
- ldy #4 ; Argument size
- jsr _main ; call the users code
+NoIRQ1: jsr callmain
; Back from main (this is also the _exit entry). Reset the IRQ vector if
; we chained it.
--- /dev/null
+;
+; Ullrich von Bassewitz, 2003-03-07
+;
+; Setup arguments for main
+;
+
+
+ .constructor initmainargs, 24
+ .import __argc, __argv
+
+
+;---------------------------------------------------------------------------
+; Setup arguments for main
+
+.proc initmainargs
+
+ rts
+
+.endproc
+
+
joy_stddrv.o \
kbhit.o \
kernal.o \
+ mainargs.o \
randomize.o \
revers.o
.export _exit
.import initlib, donelib
- .import push0, _main, zerobss
+ .import push0, callmain, zerobss
.import MEMTOP, RESTOR, BSOUT, CLRCH
.include "zeropage.inc"
jsr initlib
-; Pass an empty command line
+; Push arguments and call main()
- jsr push0 ; argc
- jsr push0 ; argv
-
- ldy #4 ; Argument size
- jsr _main ; call the users code
+ jsr callmain
; Call module destructors. This is also the _exit entry.
--- /dev/null
+;
+; Ullrich von Bassewitz, 2003-03-07
+;
+; Setup arguments for main
+;
+
+
+ .constructor initmainargs, 24
+ .import __argc, __argv
+
+
+;---------------------------------------------------------------------------
+; Setup arguments for main
+
+.proc initmainargs
+
+ rts
+
+.endproc
+
+
joy_stddrv.o \
kbhit.o \
kernal.o \
+ mainargs.o \
mouse.o \
randomize.o \
revers.o \
TIME = $A0 ; 60 HZ clock
FNAM_LEN = $B7 ; Length of filename
SECADR = $B9 ; Secondary address
-DEVNUM = $BA ; Device number
+DEVNUM = $BA ; Device number
+FNAM = $BB ; Pointer to filename
KEY_COUNT = $C6 ; Number of keys in input buffer
RVS = $C7 ; Reverse flag
CURS_FLAG = $CC ; 1 = cursor off
.export _exit
.import initlib, donelib
.import zerobss, push0
- .import _main
+ .import callmain
.import RESTOR, BSOUT, CLRCH
.import __RAM_START__, __RAM_SIZE__ ; Linker generated
jsr initlib
-; Pass an empty command line
+; Push arguments and call main
- jsr push0 ; argc
- jsr push0 ; argv
-
- ldy #4 ; Argument size
- jsr _main ; call the users code
+ jsr callmain
; Call module destructors. This is also the _exit entry.
--- /dev/null
+;
+; Ullrich von Bassewitz, 2003-03-07
+;
+; Setup arguments for main.
+; Based on code from Stefan A. Haubenthal, <polluks@web.de>
+;
+
+
+ .constructor initmainargs, 24
+ .import __argc, __argv
+
+ .include "c64.inc"
+
+;---------------------------------------------------------------------------
+; Setup arguments for main
+
+.proc initmainargs
+
+; Setup a pointer to our argv vector
+
+ lda #<argv
+ sta __argv
+ lda #>argv
+ sta __argv+1
+
+; Save the last filename as argument #0. Since the buffer we're copying into
+; is zeroed out, we don't need to add a NUL character.
+
+ ldy FNAM_LEN
+ cpy #16+1
+ bcc L0
+ ldy #16 ; Limit the length
+L0: dey
+L1: lda (FNAM),y
+ sta argv0,y
+ dey
+ bpl L1
+ inc __argc ; __argc = 1
+
+; Find argument in BASIC buffer, if found, use it as arg #1
+
+ ldy #0
+L2: lda $200,y
+ beq L9
+ iny
+ cmp #$8F ; REM token
+ bne L2
+ sty argv+2 ; Store offset
+ ldy #>$200
+ sty argv+3
+ inc __argc ; argc = 2
+
+; Done
+
+L9: rts
+
+.endproc
+
+
+;---------------------------------------------------------------------------
+; Data
+
+.data
+
+argv: .word argv0 ; Pointer to program name
+ .word $0000 ; Optional second argument
+ .word $0000 ; Last vector must always be NULL
+
+.bss
+argv0: .res 17 ; Program name
+
+
kplot.o \
kscnkey.o \
kudtim.o \
+ mainargs.o \
mouse.o \
peeksys.o \
pokesys.o \
.export _exit
.import _clrscr, initlib, donelib
- .import push0, _main
+ .import push0, callmain
.import __CHARRAM_START__, __CHARRAM_SIZE__, __VIDRAM_START__
.import __EXTZP_RUN__, __EXTZP_SIZE__
.import __BSS_RUN__, __BSS_SIZE__
jsr initlib
-; Create the (empty) command line for the program
-
- jsr push0 ; argc
- jsr push0 ; argv
-
; Execute the program code
jmp Start
cli
-; Call the user code
+; Push arguments and call main()
- ldy #4 ; Argument size
- jsr _main ; call the users code
+ jsr callmain
; Call module destructors. This is also the _exit entry.
--- /dev/null
+;
+; Ullrich von Bassewitz, 2003-03-07
+;
+; Setup arguments for main
+;
+
+
+ .constructor initmainargs, 24
+ .import __argc, __argv
+
+
+;---------------------------------------------------------------------------
+; Setup arguments for main
+
+.proc initmainargs
+
+ rts
+
+.endproc
+
+
kplot.o \
kscnkey.o \
kudtim.o \
+ mainargs.o \
peeksys.o \
pokesys.o \
randomize.o \
.exportzp ktab2, ktab3, ktab4, time, RecvBuf, SendBuf
.import initlib, donelib
- .import push0, _main
+ .import push0, callmain
.import __BSS_RUN__, __BSS_SIZE__
.import irq, nmi
.import k_irq, k_nmi, PLOT, UDTIM, SCNKEY
jsr initlib
-; Create the (empty) command line for the program
-
- jsr push0 ; argc
- jsr push0 ; argv
-
; Execute the program code
jmp Start
cli
-; Call the user code
+; Push arguments and call main()
- ldy #4 ; Argument size
- jsr _main ; call the users code
+ jsr callmain
; Call module destructors. This is also the _exit entry.
--- /dev/null
+;
+; Ullrich von Bassewitz, 2003-03-07
+;
+; Setup arguments for main
+;
+
+
+ .constructor initmainargs, 24
+ .import __argc, __argv
+
+
+;---------------------------------------------------------------------------
+; Setup arguments for main
+
+.proc initmainargs
+
+ rts
+
+.endproc
+
+
%.tgi: %.o ../../runtime/zeropage.o
@$(LD) -t module -o $@ $^
-S_OBJS = crt0.o extzp.o oserror.o oserrlist.o randomize.o fio_module.o tgi_mode_table.o
+S_OBJS = crt0.o \
+ extzp.o \
+ fio_module.o \
+ mainargs.o \
+ oserror.o \
+ oserrlist.o \
+ randomize.o \
+ tgi_mode_table.o
#--------------------------------------------------------------------------
# Drivers
.import __RAM_START__, __RAM_SIZE__ ; Linker generated
.import initlib, donelib
.import pushax
- .import _main
+ .import callmain
.import _MainLoop, _EnterDeskTop
.import zerobss
.importzp sp
jsr initlib
-; Pass an empty command line
-
- lda #0
- tax
- jsr pushax ; argc
- jsr pushax ; argv
+; Push arguments and call main()
cli
- ldy #4 ; Argument size
- jsr _main ; call the users code
+ jsr callmain
; Call module destructors. This is also the _exit entry which must be called
; explicitly by the code.
--- /dev/null
+;
+; Ullrich von Bassewitz, 2003-03-07
+;
+; Setup arguments for main
+;
+
+
+ .constructor initmainargs, 24
+ .import __argc, __argv
+
+
+;---------------------------------------------------------------------------
+; Setup arguments for main
+
+.proc initmainargs
+
+ rts
+
+.endproc
+
+
kreadst.o \
ksetlfs.o \
ksetnam.o \
+ mainargs.o \
randomize.o \
revers.o
.export _exit
.import initlib, donelib
.import zerobss, push0
- .import _main
+ .import callmain
.import CLRCH, BSOUT
.include "zeropage.inc"
jsr initlib
-; Pass an empty command line
+; Push arguments and call main()
- jsr push0 ; argc
- jsr push0 ; argv
-
- ldy #4 ; Argument size
- jsr _main ; call the users code
+ jsr callmain
; Call module destructors. This is also the _exit entry.
--- /dev/null
+;
+; Ullrich von Bassewitz, 2003-03-07
+;
+; Setup arguments for main
+;
+
+
+ .constructor initmainargs, 24
+ .import __argc, __argv
+
+
+;---------------------------------------------------------------------------
+; Setup arguments for main
+
+.proc initmainargs
+
+ rts
+
+.endproc
+
+
ktalk.o \
kunlsn.o \
kuntlk.o \
+ mainargs.o \
randomize.o \
revers.o \
tgi_mode_table.o
.export brk_jmp
.import condes, initlib, donelib
- .import push0, _main, zerobss
+ .import push0, callmain, zerobss
.import __IRQFUNC_TABLE__, __IRQFUNC_COUNT__
.include "zeropage.inc"
stx IRQVec+1
cli
-; Pass an empty command line
+; Push arguments and call main()
-NoIRQ1: jsr push0 ; argc
- jsr push0 ; argv
-
- ldy #4 ; Argument size
- jsr _main ; call the users code
+NoIRQ1: jsr callmain
; Back from main (this is also the _exit entry). Reset the IRQ vector if
; we chained it.
--- /dev/null
+;
+; Ullrich von Bassewitz, 2003-03-07
+;
+; Setup arguments for main
+;
+
+
+ .constructor initmainargs, 24
+ .import __argc, __argv
+
+
+;---------------------------------------------------------------------------
+; Setup arguments for main
+
+.proc initmainargs
+
+ rts
+
+.endproc
+
+
kbhit.o \
kernal.o \
kplot.o \
+ mainargs.o \
randomize.o \
revers.o
zap: clean
@rm -f $(EMDS) $(JOYS) $(TGIS)
-
+
.export _exit
.import initlib, donelib
.import zerobss, push0
- .import _main
+ .import callmain
.import RESTOR, BSOUT, CLRCH
.import __RAM_START__, __RAM_SIZE__ ; Linker generated
jsr initlib
-; Pass an empty command line
+; Push arguments and call main()
- jsr push0 ; argc
- jsr push0 ; argv
-
- ldy #4 ; Argument size
- jsr _main ; call the users code
+ jsr callmain
; Call module destructors. This is also the _exit entry.
--- /dev/null
+;
+; Ullrich von Bassewitz, 2003-03-07
+;
+; Setup arguments for main
+;
+
+
+ .constructor initmainargs, 24
+ .import __argc, __argv
+
+
+;---------------------------------------------------------------------------
+; Setup arguments for main
+
+.proc initmainargs
+
+ rts
+
+.endproc
+
+