Loading file to VRAM in ASM

صفحة 1/4
| 2 | 3 | 4

بواسطة aoineko

Paladin (874)

صورة aoineko

18-04-2011, 23:41

Hi all,

What is the simplest way to load a file in VRAM using assembler on MSX2?
I found the BLTVD instruction in the Sub-ROM but I'm not sure how to use it.
I'm working on a 32K cartridge (Page 1-2) using 16K of RAM (Page 3) so I don't handle any memory page switch.

To access the Sub-ROM functions, have I to change manually the Page 0's slot?

Also, I found in the MSX2 Technical Handbook that the NX/NY parameters have to be in the data to transfer... in what form?
I added 2 WORDS in front of my image with width+height information but I'm not sure this is right and I don't miss other information.

Last, I would like to know if there is any initialization to do before to be able to use Sub-ROM functions?

Login أوregister لوضع تعليقاتك

بواسطة flyguille

Prophet (3031)

صورة flyguille

19-04-2011, 16:30

oh, my boy.... you are sooo lost!

بواسطة flyguille

Prophet (3031)

صورة flyguille

19-04-2011, 16:44

1) using assembler (and not just BLOAD,S)

the fast way, is to use a call to copy RAM-> VRAM

Second, by default, BIOS-ROM (slot 0) is always selected on page 0, so you don't needs to switch to anywhere.

Third, MSX VDP, expects in its VRAM memory, information that match for a correct visualization with the SCREEN mode that it is selected.

When you are saying that you are placing a WIDTH/HEIGHT information as a tag for identify the bitmap size, well, I expect that you are talking that you want that the ASSEMBLER code reads them and sends the bitmap LOCATED IN RAM in properly format to VRAM. <- this is a bit more complicated than just to copy RAM -> VRAM.

IIRC the best way, is to use the vdp's coprocessor to place your bitmap in somewhere in the screen.
The coprocessor accepts values like WIDTH / HEIGHT size. And it saves you a lot of logical code.

بواسطة flyguille

Prophet (3031)

صورة flyguille

19-04-2011, 16:50

so an outline is:

Bload the bitmap in a reserve RAM area. (if using BASIC ram space, you will be limited to fit littles bitmaps)
Or you can to use ram pagging.

Bload your assembler code.

run your assembler code from BASIC after setting a pointer where the bitmap is loader.

the assembler code must do.

Checks if the coprocessor is free. If not, just WAIT.
fills a coprocessor command
tell to the coprocessor that execute the command
sends to the coprocesor in a loop all the bitmap data that the command is expecting.

DONE

بواسطة aoineko

Paladin (874)

صورة aoineko

19-04-2011, 23:15

Hi flyguille,

In fact, I'm doing a top-view racing game in C/ASM on a 32B ROM.
My sprites are in ROM and I use VDP command to put them in VRAM for fast copy.
If I need file access, it's only to add an option to import track (256x212x8bits image) from file.
I just need to be able to move the whole content of the file to my 1st screen buffer.

The BLTVD instruction seem to be in Sub-ROM (in Slot 3-0) so I suppose I have to switch Slot for Page 0 (or peehaps I can use CALSLT).

The thing I can't found information on is the format of data needed for the BLTVD instruction. If this instruction work like BLOAD, perhaps I have to use the same 7 bits header.

بواسطة aoineko

Paladin (874)

صورة aoineko

20-04-2011, 00:38

I fact I would like to do the equivalent to Basic's :

10 SCREEN 8
20 BLOAD"TRACK_01.SC8",S

...but in assembler.

بواسطة flyguille

Prophet (3031)

صورة flyguille

20-04-2011, 02:58

I did the same type of game "CAR II" downloadable here, but in pure BASIC (developed like in 90'), it has 20 tracks.

the worse problem was the IA of the drivers of the cars controlled by the msx

what I did, I uses different chars (16), with the same graphics, but as they are different chars number, it is uses as a guide for the IA of the drivers.

so if a computer car basically VPEEKs what is on its position on the screen, and with the char number controls the steering.

But for more complex track graphics, you can to have two layers for each track, one in VDP other in RAM, and the IA looks up the track in RAM .

Good Luck!.

بواسطة Vampier

Prophet (2409)

صورة Vampier

20-04-2011, 04:26

I fact I would like to do the equivalent to Basic's :

10 SCREEN 8
20 BLOAD"TRACK_01.SC8",S

...but in assembler.

You just need to use the mapper and load graphics into the VRAM (decompresed?)

بواسطة flyguille

Prophet (3031)

صورة flyguille

20-04-2011, 04:53

you have two approachs..

one is loading block per block of the file, send it to VRAM (sequentially)
what BLOAD ,S DOES

but if THAT method, remember it is RAW VRAM DATA, not a BITMAP.

but as you are using screen8, it is a bitmap, always 256x212x8.

for doing that, you needs to handle a FCB (file control block), and to access the disk-bios

there is a standard method to do that.

this method is normally not used when you are programming a .ROM (for a cartridge), because a cartridge ROM is supposed to works by itself.

----------------------------------------------------

Now, the other way is to have all in ROM or loaded in RAM, and just a copy RAM-VRAM

but as each screen8 is about 60K RAM, you needs to handle the mapper, and remember that a normal msx only has 128KB. so it is a wast of RAM.

--------------------------------------------------

now if you are crated a DISK-GAME, then , just use part in BASIC part in assembler

by example, the only one part of a game that really needs ASSEMBLER, is the gameplay routine...

بواسطة aoineko

Paladin (874)

صورة aoineko

21-04-2011, 01:14

I'm doing a ROM game with optional file access like King's Valley II did (for level editor).
My game is in C/ASM and is thousand lines long so I don't plan to use Basic at all. Smile

To be able to use Sub-ROM's BLTVD function (file to VRAM) with a ROM game it seem I have to use the H.STKE hook (FEDAH) to initialize it.
I tried to do this, but didn't succeed to make it work.
I don't know what is really need (in term of code, working area, etc.) to be able to use BLTVD. Sad

بواسطة flyguille

Prophet (3031)

صورة flyguille

21-04-2011, 04:16

is a problem, if it is a cartridge, the DISK_BASIC is not initiated at all, you needs to run the initiation, then to use the BDOS call to requests the file.

you know/ open read close.

صفحة 1/4
| 2 | 3 | 4