GPL on MegaSDCart

Talk about programming of homebrew games only.
User avatar
@username@
Posts: 320
Joined: Tue Oct 22, 2013 6:59 pm
Location: Scotland

Re: GPL on MegaSDCart

Post by @username@ » Wed Feb 22, 2023 11:22 pm

This is CV Demo #5

The BASIC version you can see the little green man go across the top of the screen, while the logo is downloaded to VRAM,

BASIC takes around a minute to complete the logo.

GPL takes a little under 3 seconds :D
You do not have the required permissions to view the files attached to this post.
User avatar
Mobsie
Posts: 708
Joined: Fri Jun 13, 2008 10:38 am
Location: Weinheim, Germany

Re: GPL on MegaSDCart

Post by Mobsie » Wed Feb 22, 2023 11:31 pm

😎 Cool that’s really a difference
User avatar
Scouter3d
Posts: 646
Joined: Mon Jun 28, 2010 7:02 am
Location: Wien
Contact:

Re: GPL on MegaSDCart

Post by Scouter3d » Thu Feb 23, 2023 6:57 am

Wow! I have to give this demos a comparison run :0) Cheers, TOM:0)
User avatar
@username@
Posts: 320
Joined: Tue Oct 22, 2013 6:59 pm
Location: Scotland

Re: GPL on MegaSDCart

Post by @username@ » Fri Feb 24, 2023 10:38 am

Eagerly awaiting real hardare stats :lol:
User avatar
Scouter3d
Posts: 646
Joined: Mon Jun 28, 2010 7:02 am
Location: Wien
Contact:

Re: GPL on MegaSDCart

Post by Scouter3d » Fri Feb 24, 2023 4:01 pm

Hi,

the GPL Demos speed away like lightning :0)
find videos attached... :0)

Cheers, TOM:o)
You do not have the required permissions to view the files attached to this post.
User avatar
@username@
Posts: 320
Joined: Tue Oct 22, 2013 6:59 pm
Location: Scotland

Re: GPL on MegaSDCart

Post by @username@ » Fri Feb 24, 2023 4:37 pm

Cheers Tom! - nice to see on a CV!
User avatar
@username@
Posts: 320
Joined: Tue Oct 22, 2013 6:59 pm
Location: Scotland

Re: GPL on MegaSDCart

Post by @username@ » Sat Feb 25, 2023 12:50 am

While looking at converting BASIC to GPL - I got distracted with BASIC!

Here's a little tech demo - showing how to do SPRITES in plain old BASIC - No ASM, No GPL - just any old BASIC cartridge.

There are some limitations - but those are for another time :lol: :lol:
You do not have the required permissions to view the files attached to this post.
User avatar
Scouter3d
Posts: 646
Joined: Mon Jun 28, 2010 7:02 am
Location: Wien
Contact:

Re: GPL on MegaSDCart

Post by Scouter3d » Sat Feb 25, 2023 7:10 am

You are a wizzard! ;0) - I will give it a go on the CV... Cheers, TOM:0)
User avatar
@username@
Posts: 320
Joined: Tue Oct 22, 2013 6:59 pm
Location: Scotland

Re: GPL on MegaSDCart

Post by @username@ » Sat Feb 25, 2023 12:21 pm

BASIC Sprites ... a small step for man, a giant leap for blue boxes

Here's the background, hopefully you can make it better!

Some information on how BASIC manages the screen display will make it all clear - or not - if in doubt - just mirror it :lol: !

BASIC sets the VDP with these defaults

Code: Select all

+---------+----------------+-------+---------+
| VDP Reg | Detail         | Value | Address |
|---------+----------------+-------+---------|
|  1      | 16K RAM        | $E2   |  N/A    |
|         | Ints On        |       |         |
|         | 16x16 Sprites  |       |         |
|---------|----------------|-------|---------|
|  2      | Name Table     | $04   | $1000   |
|---------|----------------|-------|---------|
|  3      | Colour Table   | $4E   | $1380   |
|---------|----------------|-------|---------|
|  4      | Pattern Table  | $00   | $0000   |
|---------|----------------|-------|---------|
|  5      | Sprite Attr    | $26   | $1300   |
|---------|----------------|-------|---------|
|  6      | Sprite Pattern | $01   | $800    |
|---------|----------------|-------|---------|
|  7      | Background     | $01   |  N/A    |
+---------+----------------+-------+---------+
The BIOS call to set the VDP address for reading, writing and register setting uses a two byte X/A to give the 16 bit address.

The function at $FE1F also adds a little flourish to it by performing an XOR of $80 to the high (X) byte.

For example, select address $1234, for reading would be $9234, for writing would be $D234. So MSB must be set - if clear assumes VDP register. For writing, the value must be OR $40, which sets the write latch.

So, how does this work from BASIC?

The display (Name Table) begins at $1002, as BASIC has a two character border left and right for old CRT displays. From the previous BIOS set address, this translates to $D002. These are maintained at RAM addresses 218 and 219, $DA and $DB.

The current column is stored at 846 ($34E).

By adding this column offset to the display address you get the current location to print at. Note that BASIC reduces the width of the screen to 28 characters.

The BASIC PRINT-able character set

Here's the part that I had to trace. The CHAR and PLOT commands do a simple addition of 160 to whatever character you give them. So 32 becomes 192. Anything over 255 is wrapped with the excess just thrown away, as it's an 8-bit value.

PRINT however, is more than a little funkadelic.

Each character requested is initially AND #$7F, so remove the MSB and reduce to a set of 0-127. This is then reduced by 0 being ignored and 13 (Carriage Return) triggering a display scroll.

Taking the character 224 ($E0), it would go through this translation.

Code: Select all

Character requested 224 ($E0)
AND #$7F becomes    96  ($60)
OR #$80             224 ($E0)
ADC #$20            256 ($00) ($100)
Armed with the above, it's easy to see that the PRINT guy misread the memo.

Here's a little program which writes the possible ASCII -> FUCV codes, to VRAM $2000.

Code: Select all

10 CLS
20 GOSUB 9800
25 POKE 218,0
28 POKE 219,224
30 FOR A=0 TO 255
31 POKE 218,A
32 POKE 219,224
36 POKE 846,0
40 PRINT CHR$(A);
50 NEXT
60 GOSUB 9800
70 END
9799 REM *** HOME ***
9800 POKE 218,2
9810 POKE 219,208
9820 POKE 846,0
9830 RETURN
Which results in these values - which can be used as a FUCV translation table

Code: Select all

00002000   00 A1 A2 A3  A4 A5 A6 A7  A8 A9 AA AB  AC 00 AE AF
00002010   B0 B1 B2 B3  B4 B5 B6 B7  B8 B9 BA BB  BC BD BE BF
00002020   C0 C1 C2 C3  C4 C5 C6 C7  C8 C9 CA CB  CC CD CE CF
00002030   D0 D1 D2 D3  D4 D5 D6 D7  D8 D9 DA DB  DC DD DE DF
00002040   E0 E1 E2 E3  E4 E5 E6 E7  E8 E9 EA EB  EC ED EE EF
00002050   F0 F1 F2 F3  F4 F5 F6 F7  F8 F9 FA FB  FC FD FE FF
00002060   00 01 02 03  04 05 06 07  08 09 0A 0B  0C 0D 0E 0F
00002070   10 11 12 13  14 15 16 17  18 19 1A 1B  1C 1D 1E 1F
00002080   00 A1 A2 A3  A4 A5 A6 A7  A8 A9 AA AB  AC 00 AE AF
00002090   B0 B1 B2 B3  B4 B5 B6 B7  B8 B9 BA BB  BC BD BE BF
000020A0   C0 C1 C2 C3  C4 C5 C6 C7  C8 C9 CA CB  CC CD CE CF
000020B0   D0 D1 D2 D3  D4 D5 D6 D7  D8 D9 DA DB  DC DD DE DF
000020C0   E0 E1 E2 E3  E4 E5 E6 E7  E8 E9 EA EB  EC ED EE EF
000020D0   F0 F1 F2 F3  F4 F5 F6 F7  F8 F9 FA FB  FC FD FE FF
000020E0   00 01 02 03  04 05 06 07  08 09 0A 0B  0C 0D 0E 0F
000020F0   10 11 12 13  14 15 16 17  18 19 1A 1B  1C 1D 1E 1F
Limitations from the above

For now, using the PRINT method means that you can only do ranges 0-31 and 161-255 in the X and Y directions. Also these are the only characters you can use to define your masterpiece.

So to display a sprite, write the Sprite attribute to $1300, and define the pattern at $800. I tend to reset the column position (846) to 0 often to stop the autosrcroll kicking in.

Cheers!

Disclaimer
Parts of this post were written by Mega the fictonal hamster, so this may or may not function in the real world.
You do not have the required permissions to view the files attached to this post.
User avatar
@username@
Posts: 320
Joined: Tue Oct 22, 2013 6:59 pm
Location: Scotland

Re: GPL on MegaSDCart

Post by @username@ » Mon Feb 27, 2023 9:39 am

Multicolour Mode

Here's a short program that will change VDP register 1 by setting M2 - thereafter use CHAR to plot each block of 4 colours.
basic83b-002.png

Code: Select all

5 CLS
12 REM *** Set VDP Register 1 to $EA ***
10 POKE 218,234
20 POKE 219,1
30 POKE 846,0
40 PRINT "A";
50 GOSUB 9800
60 FOR A=0 TO 255
70 CHAR A,23456789ABCDEF64
80 NEXT
85 GOSUB 9800
90 GOTO 90
9799 REM *** HOME ***
9800 POKE 218,2
9810 POKE 219,208
9820 POKE 846,0
9830 RETURN
You do not have the required permissions to view the files attached to this post.
Post Reply