shadowVIC – a lightweight VIC-20 emulator
Moderator: Moderators
Re: shadowVIC – a lightweight VIC-20 emulator
Meanwhile in Finland..
Pew.. Pew.. PePePew...
Pew.. Pew.. PePePew...
Re: shadowVIC – a lightweight VIC-20 emulator
LOL! Awesome!
Thanks to Mike, who pointed out that transfer instructions actually modify flags, the BASIC kind of boots now. With 29496.7295 bytes free. m)
EDIT: Nothing can possibly spoil my day now.
Thanks to Mike, who pointed out that transfer instructions actually modify flags, the BASIC kind of boots now. With 29496.7295 bytes free. m)
EDIT: Nothing can possibly spoil my day now.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
https://github.com/SvenMichaelKlose
Re: shadowVIC – a lightweight VIC-20 emulator
Thanks to Dane Bills who put in an incredible lot of time to port Panicman, BASIC boots now.
A tiny VIA emulation went in, so NMIs are enabled or disabled the classic way now.
A tiny VIA emulation went in, so NMIs are enabled or disabled the classic way now.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
https://github.com/SvenMichaelKlose
Re: shadowVIC – a lightweight VIC-20 emulator
If someone could provide a quick tutorial about how to load and start BASIC programs from assembly – that would be nice. I find the idea of turning BASIC programs into stand–alone applications quite fascinating.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
https://github.com/SvenMichaelKlose
- Mike
- Herr VC
- Posts: 4941
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: shadowVIC – a lightweight VIC-20 emulator
I usually use this code snippet:
The rest of the system should already have been initialised so far it got to the READY prompt.
Code: Select all
LDA #$01
LDX $BA ; last used device. could be fixed to a constant (like 8)
LDY #$00
JSR $FFBA ; SETLFS
LDA #Name_End - Name
LDX #Name MOD 256
LDY #Name DIV 256
JSR $FFBD ; SETNAM
LDA #$00
LDX $2B
LDY $2C
JSR $FFD5 ; LOAD (forced to BASIC start, as secondary address in SETLFS is 0)
STX $2D
STY $2E
JSR $C533 ; re-link lines
JSR $C659 ; CLR, reset TXTPTR
JMP $C7AE ; execute next statement (a.k.a. "RUN")
.Name
EQUS "MAIN"
.Name_End
Re: shadowVIC – a lightweight VIC-20 emulator
You're awesome. Meant it a little differently, though: the ready-prompt is there and the program is loaded into memory via the emulator. That's where it came to an halt. With your snippet it could also be done of course. Thanks!
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
https://github.com/SvenMichaelKlose
Re: shadowVIC – a lightweight VIC-20 emulator
Ermh… just a moment please. If I get the modularity of the kernel right, is this:
enough as long as I set the basic and the variable start (assuming that the array area is initialized based on the variable start anyway)?
Code: Select all
JSR $C533 ; re-link lines
JSR $C659 ; CLR, reset TXTPTR
JMP $C7AE ; execute next statement (a.k.a. "RUN")
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
https://github.com/SvenMichaelKlose
- Mike
- Herr VC
- Posts: 4941
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: shadowVIC – a lightweight VIC-20 emulator
You should make sure, that the byte before the BASIC start is initialised to 0. Otherwise, yes: JSR $C659 also takes care of all the other pointers that refer to $2B/$2C, $2D/$2E and(!) $37/$38.
Re: shadowVIC – a lightweight VIC-20 emulator
Oh, that's nice. Thanks again. Sounds so simple that picovic might start PRG files tomorrow morning.Mike wrote:You should make sure, that the byte before the BASIC start is initialised to 0. Otherwise, yes: JSR $C659 also takes care of all the other pointers that refer to $2B/$2C, $2D/$2E and(!) $37/$38.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
https://github.com/SvenMichaelKlose
Re: shadowVIC – a lightweight VIC-20 emulator
I loaded the program to its starting address, cleared the byte right in front of it, copied the first two or four bytes to $2b, did the two calls and the jump – and it returned to the prompt right away. Well, code says more than a thousand words:
Got it right?
Code: Select all
byte basic_starter[] = {
0x20, 0x33, 0xc5, /* jsr $c533 */
0x20, 0x59, 0xc6, /* jsr $c659 */
0x4c, 0xae, 0xc7 /* jmp $c7ae */
};
void
vic20_run_prg (char * path)
{
int i;
address load_address;
vic20_init (m[0xfffc] + (m[0xfffd] << 8));
for (i = 0; i < 500000; i++)
vic20_step ();
/* READY, Daddy! */
load_address = load_prg (path);
m[load_address - 1] = 0;
memcpy (&m[0x2b], &m[load_address], 2);
memcpy (&m[0xa000], basic_starter, sizeof (basic_starter));
pc = 0xa000;
vic20_run ();
}
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
https://github.com/SvenMichaelKlose
- Mike
- Herr VC
- Posts: 4941
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: shadowVIC – a lightweight VIC-20 emulator
Good morning!
What is needed is another version of load_prg(), which ignores the load address of the *.prg file, and instead loads the file to a given address (here: the pointer contained in $2B/$2C) and which also returns the address to the (free) byte following the last byte loaded to VIC RAM. That pointer needs to be copied to $2D/$2E before calling basic_starter:
That is being taken care by the BASIC cold start already. I just mentioned it because it can easily get forgotten with an 'inject-to-RAM' technique, when the ZP is already initialised, but BASIC hasn't been cold started still.pixel wrote:Code: Select all
m[load_address - 1] = 0;
Here's the rub: you init the BASIC start from the 2 bytes at the beginning of a BASIC program. That's either the link pointer to the next line or two 0's to signify "end of program" (this would actually mean an empty BASIC program here).Code: Select all
memcpy (&m[0x2b], &m[load_address], 2);
What is needed is another version of load_prg(), which ignores the load address of the *.prg file, and instead loads the file to a given address (here: the pointer contained in $2B/$2C) and which also returns the address to the (free) byte following the last byte loaded to VIC RAM. That pointer needs to be copied to $2D/$2E before calling basic_starter:
Code: Select all
end_address = load_prg_2(path, 256*m[0x2c]+m[0x2b]);
m[0x2d] = end_address % 256;
m[0x2e] = end_address / 256;
Re: shadowVIC – a lightweight VIC-20 emulator
Still don't get it to run. Pushed it onto Github anyway (src/prg-loader.c src/vic-20.c). Must still be something else wrong.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
https://github.com/SvenMichaelKlose
- majikeyric
- Vic 20 Afficionado
- Posts: 353
- Joined: Fri Oct 24, 2014 2:08 pm
- Website: http://majikeyric.free.fr
- Location: France
Re: shadowVIC – a lightweight VIC-20 emulator
Hi!
It seems there are incorrect results with the BCD ADD.
For example $51+$48 gives $f9 and not $99.
I would rather do this (in e_adc() , line 190 in 6502.c)
It seems there are incorrect results with the BCD ADD.
For example $51+$48 gives $f9 and not $99.
I would rather do this (in e_adc() , line 190 in 6502.c)
Code: Select all
#ifndef CPU_2A03
if (d) {
e = (a & 0x0f) + (r & 0x0f) + c;
if (e > 0x09)
e += 0x06;
e += (a & 0xf0) + (r & 0xf0);
c = 0;
if ( (e & 0xf0) > 0x90) {
e += 0x60;
c = 1;
}
} else {
#endif
Last edited by majikeyric on Wed Dec 02, 2015 3:38 am, edited 1 time in total.
Re: shadowVIC – a lightweight VIC-20 emulator
Oh. You're absolutely right. Thanks for your contribution!
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
https://github.com/SvenMichaelKlose
Re: shadowVIC – a lightweight VIC-20 emulator
The RTS instruction has been fixed. The address on the stack has to be off by one. Still doesn't run BASIC programs, tho.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
https://github.com/SvenMichaelKlose