I'm displaying a bitmap file on screen. I can load then bitmap from disk into RAM using cbm_k_load, but then I have to copy the bytes one-at-a-time into VRAM using the Address Lo/Hi/Mid and Data0 registers. Its pretty slow. Even a 320x200 image takes quite a few seconds to fully render on screen.
Is there a faster way?
Can you load a bitmap directly into VRAM?
Re: Can you load a bitmap directly into VRAM?
I think I figured it out. The kernal function "memory_copy" at FEE7 seems to do it.
So something like:
POKEW(0x2, BANK_RAM); // Read from the BANK_RAM location where I loaded the bitmap
POKEW(0x4, 0x9F23); // Point it to the Data0 register
POKEW(0x6, numBytesToCopy); // Size of my bitmap
__asm__("jsr $FEE7");
This seems to work. Are these kernal functions exposed through any C libs? I didn't see any of them in cx16.h or the other headers.
So something like:
POKEW(0x2, BANK_RAM); // Read from the BANK_RAM location where I loaded the bitmap
POKEW(0x4, 0x9F23); // Point it to the Data0 register
POKEW(0x6, numBytesToCopy); // Size of my bitmap
__asm__("jsr $FEE7");
This seems to work. Are these kernal functions exposed through any C libs? I didn't see any of them in cx16.h or the other headers.
- StephenHorn
- Posts: 565
- Joined: Tue Apr 28, 2020 12:00 am
- Contact:
Re: Can you load a bitmap directly into VRAM?
This could stand to be documented clearly, but the X16 has extended the behavior of the LOAD kernal function.
Normally, if the A register is 0, the kernal loads the file into system memory. Non-zero means the kernal should perform a verify instead.
On the X16:
Normally, if the A register is 0, the kernal loads the file into system memory. Non-zero means the kernal should perform a verify instead.
On the X16:
- If the A register is zero, the kernal loads into system memory.
- If the A register is 1, the kernal performs a verify.
- If the A register is 2, the kernal loads into VRAM, starting from $00000 + the specified starting address.
- If the A register is 3, the kernal loads into VRAM, starting from $10000 + the specified starting address.
Developer for Box16, the other X16 emulator. (Box16 on GitHub)
I also accept pull requests for x16emu, the official X16 emulator. (x16-emulator on GitHub)
I also accept pull requests for x16emu, the official X16 emulator. (x16-emulator on GitHub)
Re: Can you load a bitmap directly into VRAM?
From the manual:
VLOAD
TYPE: Command
FORMAT: VLOAD <filename>, <device>, <VERA_high_address>, <VERA_low_address>
Action: Loads a file directly into VERA RAM.
VLOAD
TYPE: Command
FORMAT: VLOAD <filename>, <device>, <VERA_high_address>, <VERA_low_address>
Action: Loads a file directly into VERA RAM.
- StephenHorn
- Posts: 565
- Joined: Tue Apr 28, 2020 12:00 am
- Contact:
Re: Can you load a bitmap directly into VRAM?
Ah, yes, if you're attempting to use BASIC to load the bitmap into VRAM, just use the VLOAD command. :3
Developer for Box16, the other X16 emulator. (Box16 on GitHub)
I also accept pull requests for x16emu, the official X16 emulator. (x16-emulator on GitHub)
I also accept pull requests for x16emu, the official X16 emulator. (x16-emulator on GitHub)
- StephenHorn
- Posts: 565
- Joined: Tue Apr 28, 2020 12:00 am
- Contact:
Re: Can you load a bitmap directly into VRAM?
If you're working from the latest repository version of cc65 and it's not there, then it's not there.
cc65 does support the X16, but that support is a little dated these days because C development got stalled by some wonkiness on the X16 side of things, and the folks I recall being the main contributors to the C development support kind of wandered away since their pull requests to cc65 couldn't be honored in a timely fashion. (In fairness, it's hard to remain motivated with something when forces beyond your control are stymying your ability to contribute.)
Developer for Box16, the other X16 emulator. (Box16 on GitHub)
I also accept pull requests for x16emu, the official X16 emulator. (x16-emulator on GitHub)
I also accept pull requests for x16emu, the official X16 emulator. (x16-emulator on GitHub)
Re: Can you load a bitmap directly into VRAM?
Thanks for all the info. I'm using C so the VLOAD function doesn't help. I'll try setting the A register to load directly into VRAM, but with the memory_copy kernal function, its so fast to copy from banked RAM now that my problem is essentially solved.
Thanks all!
Thanks all!
- desertfish
- Posts: 1123
- Joined: Tue Aug 25, 2020 8:27 pm
- Location: Netherlands
Re: Can you load a bitmap directly into VRAM?
Prog8 has a vload() function in the disk io library. It is calling the regular kernal routines to load a file, but with the correct parameters set up to make it load directly into vram.
I'm sure you can do the same in cc65 by making your own vload routine. (it's too bad that everyone has to do this, but maybe someone could make an updated/extended x16 library that others can utilize / contribute to)
I'm sure you can do the same in cc65 by making your own vload routine. (it's too bad that everyone has to do this, but maybe someone could make an updated/extended x16 library that others can utilize / contribute to)
Re: Can you load a bitmap directly into VRAM?
Ender, it's true that message is repeating the OP question that was just answered ... but sitting at the end of the message is a link to "how to unlock an iphone without itunes", so the message text is just spam.
Re: Can you load a bitmap directly into VRAM?
Oh haha, I didn't look back and notice that the message was literally the same as the OP, just with a few words changed/removed. I guess some more spam bot protections need to be added to the board.