VICE - Write to Cart Image Possible?

You need an actual VIC.

Moderator: Moderators

Post Reply
User avatar
Radical Brad
Vic 20 Devotee
Posts: 256
Joined: Sat Jun 24, 2017 8:18 pm
Website: http://www.AtomicZombie.com
Location: Kakabeka Falls, ONT
Occupation: hACKER

VICE - Write to Cart Image Possible?

Post by Radical Brad »

Having looked through the VICE manual, and all settings I have no been able to find an option to allow the VIC-20 to write to a cartridge image loaded into Block-5.

The reason I need this is because my real hardware prototype loads an auto start image to Block-5, which in my case is RAM. VICE loads this image just fine (as ROM), but my self modifying code fails, of course.

I tried turning on memory expansion (RAM) in Block-5 and then loaded the cartridge image, but it simply swaps back to ROM only.

The option I need is to load the 8K cartridge image into Block-5, but then allow it to be seen as RAM.

Any ideas from the VICE masters out there?
I have a few days away from my real VIC, and want to keep on developing my new OS.

Cheers!
Brad
groepaz
Vic 20 Scientist
Posts: 1180
Joined: Wed Aug 25, 2010 5:30 pm

Re: VICE - Write to Cart Image Possible?

Post by groepaz »

just enable RAM in block5, then load the cartridge binary as a regular .prg (ie NOT "attach cartridge" - which will always use ROM)
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
User avatar
Radical Brad
Vic 20 Devotee
Posts: 256
Joined: Sat Jun 24, 2017 8:18 pm
Website: http://www.AtomicZombie.com
Location: Kakabeka Falls, ONT
Occupation: hACKER

Re: VICE - Write to Cart Image Possible?

Post by Radical Brad »

Thanks for the tip.

I am not a regular emulator user, so I am not sure how to go from a binary file to the required .PRG directly from the assembler I am using (Kowalski Macro-assembler). I can save a binary image with an offset, but it has no concept of .PRG files.

I should also mention that I need the auto-start code in block-5 so the VIC vectors to my required address on power up.

I am using this code to set my code to Block-5, and then I export an 8K .BIN file at location 40960...

Code: Select all

; ////////////////////////////////////////////////////////////////////////////////////////////
; ////////// BLOCK 5 START SEQUENCE
; ////////////////////////////////////////////////////////////////////////////////////////////

; START ADDRESS = 40969 @ 40960 TO 40961
 .ORG 40960
 .BYTE <40969,>40969
 
; RESET ADDRESS = 40969 @ 40962 TO 40963
 .ORG 40962
 .BYTE <40969,>40969
 
; BOOT CODE = a0CBM @ 40964 TO 40968
 .ORG 40964
 .BYTE 65,48,195,194,205
  
; PROGRAM START @ 40969 TO 49151
 .ORG 40969
 
This works well as a ROM image, but does not allow writes to Block-5 due to there being no "allow ROM as RAM" setting in VICE that I can find.

Perhaps it's time for me to look for another cross-assembler?
I only need this to develop my new OS assembler on the VIC.

Thanks,
Brad

groepaz wrote:just enable RAM in block5, then load the cartridge binary as a regular .prg (ie NOT "attach cartridge" - which will always use ROM)
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: VICE - Write to Cart Image Possible?

Post by Mike »

Try:

Code: Select all

.org  $9FFE
.word $A000
Greetings,

Michael

P.S. the repeated .org directives in your sample code above are completely redundant
User avatar
Radical Brad
Vic 20 Devotee
Posts: 256
Joined: Sat Jun 24, 2017 8:18 pm
Website: http://www.AtomicZombie.com
Location: Kakabeka Falls, ONT
Occupation: hACKER

Re: VICE - Write to Cart Image Possible?

Post by Radical Brad »

Thanks Mike,
I see what that is doing... adding the start address of the code so it is looks like a standard .PRG file.
I need to learn more about VICE and The Kernal to continue on this path!

I added the code, and saved the binary from $9FFE, and a total length of 8K + 2 Bytes.
I setup VICE to have RAM only in Block-5.
I then renamed the .65b file to .PRG and dragged it into the VICE window.
It tried to do a LOAD and RUN, but nothing happened.

Seems I am on the wrong path with this anyhow.
My code does not live well with any Kernal functionality, and even though I have a full 32K installed, my code expects the screen to be at the location of a non expanded VIC.

I only ventured into "Cross Dev" land due to some time away form my real hardware, but I now realize that it is best that I stay on the path of using the real VIC to do all development.

Thanks,
Brad
Mike wrote:Try:

Code: Select all

.org  $9FFE
.word $A000
Greetings,
Michael
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: VICE - Write to Cart Image Possible?

Post by Mike »

Radical Brad wrote:It tried to do a LOAD and RUN, but nothing happened.
Press Alt-R to do a soft reset (i.e. without clearing RAM).
User avatar
Radical Brad
Vic 20 Devotee
Posts: 256
Joined: Sat Jun 24, 2017 8:18 pm
Website: http://www.AtomicZombie.com
Location: Kakabeka Falls, ONT
Occupation: hACKER

Re: VICE - Write to Cart Image Possible?

Post by Radical Brad »

Thanks,
I shall give it another try again at lunchtime.
I was using VICE as a lunch hour pass-time at work, possibly to aid in development of my OS.

The way I am working from home base makes it easy...
Code using any assembler that can make a binary image.
Save the image, and click on my converter program.
My converter sends the image to an AVR that boot loads the 32K SRAM.
The time from "assemble" to real VIC is about 2 seconds.

I don't want to change anything in my code to use VICE, I just figured it may be easy to do the same type of "assemble and go" rapid development I am used to. not sure how often I will really use it though.

I almost feel guilty for "cheating" on my VIC by opening an emulator!

Brad

Mike wrote:
Radical Brad wrote:It tried to do a LOAD and RUN, but nothing happened.
Press Alt-R to do a soft reset (i.e. without clearing RAM).
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: VICE - Write to Cart Image Possible?

Post by Mike »

Radical Bard wrote:I don't want to change anything in my code to use VICE
I suppose it will take some time until *you* will get to write programs that genuinely show different behaviour on VICE compared to real hardware. Over the years, VICE has got very accurate in its emulation. In most cases, where people complain about 'errorneous' results in VICE, the true reason behind that is lack of knowledge how to use VICE correctly as tool.

In your case, you wouldn't have got a different result on the VIC-20, either. When you soft-load a cartridge image into RAM at BLK5, from mass storage, you'll have to do a reset to start the cartridge program in any case.
The time from "assemble" to real VIC is about 2 seconds.
IMO, those quick turn-around times easily lead to a sloppy programming style, in the worst case verging to shotgun programming.

My current project is just at build #33 - after 2 months! 8)
User avatar
Radical Brad
Vic 20 Devotee
Posts: 256
Joined: Sat Jun 24, 2017 8:18 pm
Website: http://www.AtomicZombie.com
Location: Kakabeka Falls, ONT
Occupation: hACKER

Re: VICE - Write to Cart Image Possible?

Post by Radical Brad »

I agree that VICE is the best Commodore emulator going by far, and highly accurate. Unless I dabble in crazy raster timed effects, I doubt i could "break" it.

My hardware does do something that may not be achievable in VICE though. I realized what this was on the way to work this morning.

What V2K does on boot is forces the VIC-20 reset active while it preloads the 32 RAM with my operating system in Blocks 1,2,3 and 5.
Once loaded, it then holds the SRAM write enable high for 2 seconds while my OS initializes. During this initialization, I call some of the Kernal routines to initialize hardware. Because I am forcing the SRAM to act as ROM during this sequence, it does not get trashed, and the Kernal does not shift the video memory.

I would just need to stop using the Kernal and write my own init. routines, but like you once mentioned... no point wasting space on code that is already in ROM, and does the job.

Brad



Mike wrote:
Radical Bard wrote:I don't want to change anything in my code to use VICE
I suppose it will take some time until *you* will get to write programs that genuinely show different behaviour on VICE compared to real hardware. Over the years, VICE has got very accurate in its emulation. In most cases, where people complain about 'errorneous' results in VICE, the true reason behind that is lack of knowledge how to use VICE correctly as tool.

In your case, you wouldn't have got a different result on the VIC-20, either. When you soft-load a cartridge image into RAM at BLK5, from mass storage, you'll have to do a reset to start the cartridge program in any case.
The time from "assemble" to real VIC is about 2 seconds.
IMO, those quick turn-around times easily lead to a sloppy programming style, in the worst case verging to shotgun programming.

My current project is just at build #33 - after 2 months! 8)
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: VICE - Write to Cart Image Possible?

Post by Mike »

Radical Brad wrote:My hardware does do something that may not be achievable in VICE though.
From the viewpoint of VICE, like it is with the VIC-20 itself, your hardware appears just like any other cartridge.

It just needs a fixed design, a thorough documentation, and an heightened interest of one of the VICE maintainers to 'pour' this into an extension for VICE. Like groepaz actually did with my VFLI mod.

...

And my current project will be able to interact with VGER-20 in a way you'd not probably expect. :mrgreen:
User avatar
Radical Brad
Vic 20 Devotee
Posts: 256
Joined: Sat Jun 24, 2017 8:18 pm
Website: http://www.AtomicZombie.com
Location: Kakabeka Falls, ONT
Occupation: hACKER

Re: VICE - Write to Cart Image Possible?

Post by Radical Brad »

Having a V2K mode in VICE would certainly be an achievement. I have a long way to go on that one!
When I was digging deep into VICE dox, I seen your modified palette and VFLI extensions... very cool.

Once I get through this initial video hardware development stage, I will take the time to study the Kernal in more detail, possibly leveraging more of what is has to offer. Logic development is going to take me the rest of this year for sure.

Brad
Mike wrote:
Radical Brad wrote:My hardware does do something that may not be achievable in VICE though.
From the viewpoint of VICE, like it is with the VIC-20 itself, your hardware appears just like any other cartridge.

It just needs a fixed design, a thorough documentation, and an heightened interest of one of the VICE maintainers to 'pour' this into an extension for VICE. Like groepaz actually did with my VFLI mod.

...

And my current project will be able to interact with VGER-20 in a way you'd not probably expect. :mrgreen:
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: VICE - Write to Cart Image Possible?

Post by Mike »

Radical Brad wrote:Once I get through this initial video hardware development stage, I will take the time to study the Kernal in more detail, possibly leveraging more of what is has to offer. Logic development is going to take me the rest of this year for sure.
That sounds like a plan. :)

Good luck! :D
User avatar
Radical Brad
Vic 20 Devotee
Posts: 256
Joined: Sat Jun 24, 2017 8:18 pm
Website: http://www.AtomicZombie.com
Location: Kakabeka Falls, ONT
Occupation: hACKER

Re: VICE - Write to Cart Image Possible?

Post by Radical Brad »

Thanks!
I may need a bit of luck this weekend as I power up the new 25MHz SyncGen in hopes that the timing holds up.
For sure it would hold up on a real PCB, but it is a goal to also make it work on the breadboard first.

I have been over the timing "worst case" propagation delay numbers many times, and although I may be looking over the edge of cliff, I should be able to avoid falling. Time will tell.

Brad
Mike wrote:
Radical Brad wrote:Once I get through this initial video hardware development stage, I will take the time to study the Kernal in more detail, possibly leveraging more of what is has to offer. Logic development is going to take me the rest of this year for sure.
That sounds like a plan. :)

Good luck! :D
Post Reply