SJLOAD-20 release 06

Basic and Machine Language

Moderator: Moderators

Diddl
Vic 20 Afficionado
Posts: 425
Joined: Wed Jun 10, 2009 3:18 am

SJLOAD-20 release 06

Post by Diddl »

Here is SJLOAD-20 (for VIC-20) release 06 (thanks to Hydrophilic!)


Release Info:

+ SJLOAD: Improved loading speed by 40%

+ SJLOAD: Now nearly all kernal IO vectors used: CHKIN,CKOUT,BSOUT,BASIN,CLALL,CLRCH (not only LOAD, SAVE)

This improves data access to jiffy devices (also in BASIC).
Is not supported in Mini Wedge (Wedge in 3K LO-RAM, memory config F7).

+ SJLOAD: Messages only in direct mode. In program mode messages are suppressed.


Binaries for $0400 and $B000 are included.

Source code is included.

You can simply change startaddress and switch on/off modules (SJSAVE, PRINT ADDRESS RANGE, BASIC IO VECTORS).


Download from my HP: sjload r06


Have fun!
User avatar
nbla000
Salmon Run
Posts: 2582
Joined: Thu Oct 13, 2005 8:58 am
Location: Italy

Post by nbla000 »

Hi Diddl,

I've just tested this Sjload version (both $b0 and $04) with my sd2brwse porting on a Vic + 32k expansion and I have the same problem noticed with new FE3 firmware r19 so the problem should be inside these routines...

No problems with SJLOAD05...

The problem is that after the JSR LOAD I got a blinking cursor.

Btw looking inside the asm file I've seen that you have added some compilation option like my modified SJLOAD 05 that I sent you, many thanks, I will compile it with BASIO = 0 and or PRINTADDRESS = 0 to see if something changes.
Mega-Cart: the cartridge you plug in once and for all.
User avatar
nbla000
Salmon Run
Posts: 2582
Joined: Thu Oct 13, 2005 8:58 am
Location: Italy

Post by nbla000 »

update:

I've compiled SJLOAD06 in a minimal mode:
SJSAVE = 0
BASIO = 0
PRINTADDRESS = 0

But I still have the problem, if I load a program from the prompt, all is ok but from sd2brwse after the JSR LOAD the cursor blink, and if I hit the RETURN key, the screen clears as it was an INPUT prompt and after it goes to a bad location (clear the screen).
I will try to debug this problem in VICE btw any idea for the reason ?
Mega-Cart: the cartridge you plug in once and for all.
Diddl
Vic 20 Afficionado
Posts: 425
Joined: Wed Jun 10, 2009 3:18 am

Post by Diddl »

Could you send me a mini program to show this problem?

Or what I have to do, simply call LOAD from a assembler code works fine form, BASIC does nothing else?
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Hi, Diddl, hi, nbla000,

I've looked at sjload06.asm; and at least that part look a bit strange.

There's the wedge init, storing a new address into the kernel load vector:

Code: Select all

MY_WEDGE_INIT
_relo5000 = . +1
  lda #<MY_LOAD
  ldx #>MY_LOAD
  sta PTR_LOAD
  stx PTR_LOAD +1
Now, the kernel load routine expects in A, whether load, or verify; and in X/Y a load address, if 0 was specified as secondary address in SETLFS. That value in X/Y overrides the value contained in the *.prg file itself!

But here ...

Code: Select all

  ; LOAD VECTOR                         :: "fnam",PA,SA[,loadadr]
MY_LOAD  subroutine
  ldx SY_DN                             ; PA (device#)
  cpx #4
  bcs .0
  jmp $f549                             ; OLD LOAD PROC
... X is already toast.

And this here, later in the MYLOAD routine:

Code: Select all

  ldx SY_SA                             ; SA
  beq .00                               ; SA=0 -->
  [...]
.00                                     ; SA=0: LOAD PROGRAM AT $c3
_relo0085 = . +1
  jsr FRMWORD2                          ; GET WORD VALUE
  lda LOADPTR +1
  ldx LOADPTR
would not provide the same behaviour as the kernel load routine, unless $C3/$C4 are initialised first, i.e. you might try inserting these instructions:

Code: Select all

MY_LOAD  subroutine
  stx $c3                               ; ** init $c3/$c4 in case of sec. add. =0,
  sty $c4                               ; ** and fast load commences
  ldx SY_DN                             ; PA (device#)
  cpx #4
  bcs .0
  ldx $c3                               ; ** restore X for kernel load
  jmp $f549                             ; OLD LOAD PROC
Greetings,

Michael

P.S.: And I'm also not sure how SJLOAD06 handles sec. add. =1. In that case, $C3/$C4 should be initialised from the first two bytes of the file, but I can't see the necessary code for that ...
Diddl
Vic 20 Afficionado
Posts: 425
Joined: Wed Jun 10, 2009 3:18 am

Post by Diddl »

Thanks Michael

You are right, it is a bug, will fix it.

It is only strange cause v18a make same and nbla000 reports no problem with this?

Maybe another bug? will wait until nbla send me his program.
Diddl
Vic 20 Afficionado
Posts: 425
Joined: Wed Jun 10, 2009 3:18 am

Post by Diddl »

No!

Kernal makes "STX $c3" bevore LOAD vector is called:

Code: Select all

.C:f542   86 C3      STX $C3
.C:f544   84 C4      STY $C4
.C:f546   6C 30 03   JMP ($0330)
.C:f549   85 93      STA $93
.C:f54b   A9 00      LDA #$00
.C:f54d   85 90      STA $90
.C:f54f   A5 BA      LDA $BA
.C:f551   D0 03      BNE $F556
.C:f553   4C 96 F7   JMP $F796
Diddl
Vic 20 Afficionado
Posts: 425
Joined: Wed Jun 10, 2009 3:18 am

Post by Diddl »

Mike wrote:P.S.: And I'm also not sure how SJLOAD06 handles sec. add. =1. In that case, $C3/$C4 should be initialised from the first two bytes of the file, but I can't see the necessary code for that ...
SJLOAD handles

SA=0:
load from $C3/$c4 address, usually BASIC start if called from interpreter.

SA=1:
load from address in the file (first two bytes)

SA=2 (only in FE3 wedge and sjload):
load from $C3/$c4 address and use first two bytes in file as data (not address)


also only in FE3 and SJLOAD, you can give an address as parameter in case of SA=0 and SA=2.

Maybe this is the problem of NBLA, but this was also so with v018a and all FE3 bevore.
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Oh, indeed. :?

In the meantime I've also answered my other question myselves, you store the first two bytes into LOADEND, and then use that pointer to store into memory.

Maybe nbla000 could also provide in source, how sd2browse calls the kernal load routine? Here's part of the source of sd2browse 0.6 by nojoopa:

Code: Select all

; setup load
setupload:
lda #1      ; filenr
ldx device  ; unitnr
ldy #1      ; sec.address (,1)
jsr SETLFS
lda disknamepetlen  ; a = filenamelen
ldx #<disknamepet
ldy #>disknamepet   ; x:y->filename
jsr SETNAM

; copy LOAD & RUN code to loadrunpos
ldy #0
ldx #loadrunend-loadrunstart
- lda loadrunstart,y
sta loadrunpos,y
iny
dex
bne -
jmp loadrunpos  ; jump to loadrunpos

; (the following code is executed at loadrunpos)
loadrunstart    ; start of code to copy
!pseudopc loadrunpos {
; load program
;
lda #0      ; a = 0: load
jsr LOAD
; error detection would be nice :)

; save end address
stx $2d
sty $2e

; autostart program
; (from comp.sys.cbm)
;
jsr $a659   ; reset pointers etc...
jmp $a7ae   ; BASIC warm start
}
loadrunend  ; end of code to copy
nbla000 surely needed correct the addresses of the last two JSR calls. BASIC programs - then loaded with sec. add. 0 also would require a jsr $c533 to relink the pointers. Parts of the load code are stored into screen memory - maybe nbla000 removed that alltogether, etc.
Diddl
Vic 20 Afficionado
Posts: 425
Joined: Wed Jun 10, 2009 3:18 am

Post by Diddl »

Mike wrote: ; error detection would be nice :)
Indeed!

In case of error this code wouldn't work. Problem isn't recognized and anything (but not the load end address) will be stored in ($2d/$2e) .
User avatar
nbla000
Salmon Run
Posts: 2582
Joined: Thu Oct 13, 2005 8:58 am
Location: Italy

Post by nbla000 »

My load code porting for the vic is a little bit different, There is a portion here:

Code: Select all

startloading:
ldy #1      ; sec.address (,1) (default for any start mode except for RUN)

lda tmpptr          ;zp location setted before to check the RUN mode
cmp #1             ;is RUN the start mode ? (1 = RUN)
bne startloadingb

ldy #0      ; sec.address (,0) for RUN start mode
startloadingb:
lda #1      ; filenr
ldx device  ; unitnr

jsr SETLFS
lda disknamepetlen  ; a = filenamelen
ldx #<disknamepet
ldy #>disknamepet   ; x:y->filename
jsr SETNAM

; copy LOAD & RUN code to loadrunpos ($33c for the vic)
ldy #0
ldx #loadrunend-loadrunstart
- lda loadrunstart,y
sta loadrunpos,y
iny
dex
bne -
jmp loadrunpos  ; jump to loadrunpos

; (the following code is executed at loadrunpos $33c for the Vic)
loadrunstart    ; start of code to copy


lda #0      ; a = 0: load
                          ;Load start address used only in RUN start mode (sec.address (,0) on SETLFS)
ldx basicstartaddress_lo  ;Pointer: Start of Basic lo byte
ldy basicstartaddress_hi  ;Pointer: Start of Basic hi byte

jsr LOAD
; error detection would be nice :)

; save end address
stx $2d
sty $2e
The autostart code for the vic is different too of course btw my problem is before, when I simply select the item the loading process does not start and I've a cursor blink.

jsr LOAD
; error detection would be nice :)
Yes nice but not essential at least until now ;-)
Mega-Cart: the cartridge you plug in once and for all.
Diddl
Vic 20 Afficionado
Posts: 425
Joined: Wed Jun 10, 2009 3:18 am

Post by Diddl »

> jsr LOAD

What is the address for LOAD? if it is $f542 or the kernel jmp table it is ok and should work fine.


Ian has sent me your beta code, will test it myself at evening.
User avatar
nbla000
Salmon Run
Posts: 2582
Joined: Thu Oct 13, 2005 8:58 am
Location: Italy

Post by nbla000 »

Diddl wrote:> jsr LOAD

What is the address for LOAD? if it is $f542 or the kernel jmp table it is ok and should work fine.
LOAD = $ffd5

.C:ffd5 4C 42 F5 JMP $F542
Ian has sent me your beta code, will test it myself at evening.
OK, in the meantime, I try to test it on VICE on lunchbreak :wink:
Mega-Cart: the cartridge you plug in once and for all.
User avatar
nbla000
Salmon Run
Posts: 2582
Joined: Thu Oct 13, 2005 8:58 am
Location: Italy

Post by nbla000 »

Diddl wrote:Ian has sent me your beta code, will test it myself at evening.
OK testing a bit this version (with ,8,1 locked like the c64 version), I have a similar behaviour (the cursor blink) but when I press RETURN, the loaded programs works, btw the problems seems to be on chin chrin pointers, here is the code where the chrin loops:

Code: Select all

; e5e5 - Input From Keyboard ?!?!
e5e8   A5 C6      LDA $C6  ; <-- keyboard buffer
e5ea   85 CC      STA $CC
e5ec   8D 92 02   STA $0292
e5ef   F0 F7      BEQ $E5E8
and this is the code that goes here:

Code: Select all

13d1   A5 29      LDA $29
13d3   A2 1C      LDX #$1C
13d5   A0 18      LDY #$18
13d7   20 BD FF   JSR $FFBD  ;setnam
13da   A9 01      LDA #$01
13dc   AE DE 17   LDX $17DE
13df   A0 00      LDY #$00
13e1   20 C0 FF   JSR $FFC0  ;(iopen) from ($031a) = [F40A] 
13e4   A2 01      LDX #$01
13e6   20 C6 FF   JSR $FFC6 ; (ichkin) ; set logical file number #1 as input
13e9   20 CF FF   JSR $FFCF  ;(ichrin) <-- here should read from disk while reads from keyboard
(ichkin) get pointers from $31e and here there is $bbf9, original [F2C7]

(ichrin) get pointers from $324 and here there is $bc4c, original [F20E]

With the new version I read first 2 bytes of the file to load so I will set the proprer memory configuration and ichrin fails when I try to load these bytes...
Mega-Cart: the cartridge you plug in once and for all.
Diddl
Vic 20 Afficionado
Posts: 425
Joined: Wed Jun 10, 2009 3:18 am

Post by Diddl »

Thank you for testing, will look at this todays evening.


Is it possible status (ST, ($90)) is not 0 bevore calling <ichkin>?

In this case maybe ChkIn fails and next call to <ichrin> give byte from standard device (keyboard).
Post Reply