Multi-Part Loader - Yes or No

Basic and Machine Language

Moderator: Moderators

Vic40
Vic 20 Newbie
Posts: 18
Joined: Fri Jan 04, 2008 8:13 am

Post by Vic40 »

Thanks Mike. I will add the POKE 6656,0.

The NEW is probably only working as nothing has been loaded into this location yet - I've only tested this straight after starting a Vice session.

Will need to leave the "fix" for the PEEK(186) problem in if Vice cannot be trusted.
User avatar
Mike
Herr VC
Posts: 5134
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

I doubt it's a problem in VICE. After all, the BASIC and KERNAL ROM blankly don't know they're running on VICE.

If there is anything else executed between POKE 824,PEEK(186), and PEEK(824), I'd put that under extra scrutiny.

Furthermore, the NEW is not executed before PEEK(186) in my example, it's just PRINTed beforehand.

Michael
Vic40
Vic 20 Newbie
Posts: 18
Joined: Fri Jan 04, 2008 8:13 am

Post by Vic40 »

Mike,

On looking at my code a little closer I found that I had actually entered the following in which the "PEEK(186)" appears within the LOAD statement that is printed on the screen.

Code: Select all

100 PRINT"{CLR}POKE44,26:POKE6656,0:NEW"
110 PRINT"{2 DOWN}LOAD"CHR$(34)"PART2"CHR$(34)",PEEK(186)"
120 POKE631,19:POKE632,13:POKE633,131:POKE198,3
Your code in which the PEEK is executed before the NEW works fine. But as the above does not (I get the PRESS PLAY ON TAPE message) then it would seem to suggest that the NEW (or something) does indeed alter location 186?. I am testing on Vice1.22 if that makes any difference?
User avatar
Jeff-20
Denial Founder
Posts: 5764
Joined: Wed Dec 31, 1969 6:00 pm

Post by Jeff-20 »

Why is NEW needed? If the memory is too tight, why not CLR in the basic script?
High Scores, Links, and Jeff's Basic Games page.
Vic40
Vic 20 Newbie
Posts: 18
Joined: Fri Jan 04, 2008 8:13 am

Post by Vic40 »

I was having problems getting the second part to load and adding the NEW seemed to be the only way to get it to load correctly. Having said that I have just removed the NEW and it now looks like I don't actually need it.

However, the following program which now doesn't have the NEW also exhibits the same "problem" with location 186.

Code: Select all

100 PRINT"{CLR}POKE44,26:POKE6656,0" 
110 PRINT"{2 DOWN}LOAD"CHR$(34)"PART2"CHR$(34)",PEEK(186)" 
120 POKE631,19:POKE632,13:POKE633,131:POKE198,3 
User avatar
nbla000
Salmon Run
Posts: 2582
Joined: Thu Oct 13, 2005 8:58 am
Location: Italy

Post by nbla000 »

why you don't change row 110 to:

Code: Select all

110 PRINT"{2 DOWN}LOAD"CHR$(34)"PART2"CHR$(34)","PEEK(186) 
Mega-Cart: the cartridge you plug in once and for all.
Vic40
Vic 20 Newbie
Posts: 18
Joined: Fri Jan 04, 2008 8:13 am

Post by Vic40 »

nbla000 wrote:why you don't change row 110 to:

Code: Select all

110 PRINT"{2 DOWN}LOAD"CHR$(34)"PART2"CHR$(34)","PEEK(186) 
Thanks - your code matches the code that Mike originally provided and does work. What happened was that I mis-typed it. But you are right the reason why the code below doesn't work is purely academic.

Code: Select all

110 PRINT"{2 DOWN}LOAD"CHR$(34)"PART2"CHR$(34)",PEEK(186)" 
User avatar
Mike
Herr VC
Posts: 5134
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Vic40 wrote:Thanks - your code matches the code that Mike originally provided and does work. What happened was that I mis-typed it. But you are right the reason why the code below doesn't work is purely academic.

Code: Select all

110 PRINT"{2 DOWN}LOAD"CHR$(34)"PART2"CHR$(34)",PEEK(186)" 
Quite simple: While the parameters of LOAD are scanned, BASIC initialises address 186 with the default value of 1:

The relevant part of the ROM reads:

Code: Select all

.C:e1d1   A9 00      LDA #$00
.C:e1d3   20 BD FF   JSR $FFBD
.C:e1d6   A2 01      LDX #$01  ; 1 = tape
.C:e1d8   A0 00      LDY #$00
.C:e1da   20 BA FF   JSR $FFBA  ; set default value for LFN and device
.C:e1dd   20 03 E2   JSR $E203
.C:e1e0   20 54 E2   JSR $E254  ; (try to) read filename
So, when the filename is scanned, it's already too late. That also would happen on a real VIC.

Michael
Richard James
Vic 20 Devotee
Posts: 270
Joined: Mon Feb 04, 2008 6:06 am

Post by Richard James »

Vic40 wrote:What happened was that I mis-typed it. But you are right the reason why the code below doesn't work is purely academic.

Code: Select all

110 PRINT"{2 DOWN}LOAD"CHR$(34)"PART2"CHR$(34)",PEEK(186)" 
That reads as

Code: Select all

PRINT "{2 DOWN}LOAD"
PRINT CHR$(34)
PRINT "PART2"
PRINT CHR$(34)
PRINT ",PEEK(186)"
Difference is that in one version the peek(186) takes place after being printed and in the other peek(186) takes place during the printing. Leading to the problem that Mike mentions.

The difference between

Code: Select all

10 PRINT "HELLO"
20 PRINT "NEW"
and

Code: Select all

10 PRINT "HELLO"
20 NEW
User avatar
Mike
Herr VC
Posts: 5134
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Vic40 wrote:

Code: Select all

100 PRINT"{CLR}POKE44,26:POKE6656,0"
Here you removed two commands to save for space, which clearly are not worth the trouble (also @Jeff:)

I would keep NEW, as it correctly initialises the start of variables (45/46) before the LOAD commences.

Second, the Right Thing(TM) to do is also keep 'POKE 43,0'. If you leave it out, and the low-byte of BASIC start has any other value before your loader is started, chances are that the loader again won't work.

Michael
Vic40
Vic 20 Newbie
Posts: 18
Joined: Fri Jan 04, 2008 8:13 am

Post by Vic40 »

Mike wrote:
Vic40 wrote:

Code: Select all

100 PRINT"{CLR}POKE44,26:POKE6656,0"
Here you removed two commands to save for space, which clearly are not worth the trouble (also @Jeff:)

I would keep NEW, as it correctly initialises the start of variables (45/46) before the LOAD commences.

Second, the Right Thing(TM) to do is also keep 'POKE 43,0'. If you leave it out, and the low-byte of BASIC start has any other value before your loader is started, chances are that the loader again won't work.

Michael
Mike, I will re-instate both the POKE43,0 and the NEW - I was just removing things to work out what was causing the PEEK(186) "problem". Thanks for all of your help on this one.
Post Reply