Jump to content

Recommended Posts

I've looked at all examples and read the manual, I'm just trying to fill the screen with a solid tile but only the sprite shows up, please point out why?

 

    MODE 0

    DEFINE SPRITE 0, 1, happy_face
    DEFINE CHAR 10, 1, game_bitmaps
    DEFINE COLOR 10 ,1 , game_colors

    player_x = 50
    player_y = 100
    face_color = 10
    #score = 0

    GOSUB update_score

    SCREEN DISABLE
    GOSUB draw_level
    SCREEN ENABLE


game_loop:
    IF cont1.up THEN
        player_y = player_y - 1
    END IF

    IF cont1.down THEN
    player_y = player_y + 1
    END IF

    IF cont1.left THEN
		player_x = player_x - 1
	END IF

    IF cont1.right THEN
       player_x = player_x + 1
    END IF

    SPRITE 0, player_y-1, player_x, 0, face_color

    #score = #score + 1
    GOSUB update_score
    WAIT

    GOTO game_loop

update_score:	PROCEDURE
    PRINT AT 2, #score, "0"
END


draw_level:	PROCEDURE
    'The screen is a 32x24 grid located at the VRAM address $1800-$1aff.
    'It can be accessed using VPOKE (writing) and VPEEK (reading).

    FOR #c = $1800 TO $1aff STEP 1
        VPOKE #c, 10
    NEXT #c
END

happy_face:
    BITMAP "......XXXX......"
    BITMAP "....XXXXXXXX...."
    BITMAP "...XXXXXXXXXX..."
    BITMAP "..XXXXXXXXXXXX.."
    BITMAP ".XXXXXXXXXXXXXX."
    BITMAP ".XXXXXXXXXXXXXX."
    BITMAP "XXXX..XXXX..XXXX"
    BITMAP "XXXX..XXXX..XXXX"
    BITMAP "XXXXXXXXXXXXXXXX"
    BITMAP "XXXXXXXXXXXXXXXX"
    BITMAP ".XXXXXXXXXXXXXX."
    BITMAP ".XXX..XXXX..XXX."
    BITMAP "..XXX......XXX.."
    BITMAP "...XXX....XXX..."
    BITMAP "....XXXXXXXX...."
    BITMAP "......XXXX......"


game_bitmaps:
    BITMAP "XXXXXXXX"
    BITMAP "XXXXXXXX"
    BITMAP "XXXXXXXX"
    BITMAP "XXX..XXX"
    BITMAP "XXX..XXX"
    BITMAP "XXXXXXXX"
    BITMAP "XXXXXXXX"
    BITMAP "XXXXXXXX"

game_colors:
    DATA BYTE $16

 

Link to comment
https://forums.atariage.com/topic/373478-my-cv-basic-questions/
Share on other sites

From what I can see, you need to set your colors for each row of pixels in the tile defined in game_bitmaps:

11 hours ago, Lillapojkenpåön said:
game_colors:
    DATA BYTE $16

If you change this to "DATA BYTE $16,$16,$16,$16,$16,$16,$16,$16" you'll have a black screen filled with red dots.

  • Like 1
2 hours ago, skywaffle said:

From what I can see, you need to set your colors for each row of pixels in the tile defined in game_bitmaps:

If you change this to "DATA BYTE $16,$16,$16,$16,$16,$16,$16,$16" you'll have a black screen filled with red dots.

I tried it with both
DEFINE COLOR 10 ,8 , game_colors
and
DEFINE COLOR 10 ,1 , game_colors

it compiles successfully but it's still just a black background 😢

1 hour ago, Lillapojkenpåön said:

I tried it with both
DEFINE COLOR 10 ,8 , game_colors
and
DEFINE COLOR 10 ,1 , game_colors

it compiles successfully but it's still just a black background 😢

You used color $16 (this is black for pixels set, and red for pixels clear).

 

CVBasic clears the memory on start, and you only defined a single DATA BYTE $16. It isn't enough, you need to repeat eight times the value $16.

 

I've changed that single line and it works just fine (see the screenshot with the DATA BYTE line selected)

 

CapturadePantalla2024-10-07ala(s)11_38_11.thumb.png.3c8cad1b3fb14861b01c927af00e95f7.png 

  • Like 1
23 minutes ago, nanochess said:

You used color $16 (this is black for pixels set, and red for pixels clear).

 

CVBasic clears the memory on start, and you only defined a single DATA BYTE $16. It isn't enough, you need to repeat eight times the value $16.

 

I've changed that single line and it works just fine (see the screenshot with the DATA BYTE line selected)

 

CapturadePantalla2024-10-07ala(s)11_38_11.thumb.png.3c8cad1b3fb14861b01c927af00e95f7.png 

 Ok thanks, I give up then

igiveup.thumb.png.cce3ffdcb0c0b52ad39a53c9932807b1.png

Posted (edited)
1 hour ago, nanochess said:

Haha you are doing something incredibly wrong. Do a comparison with this.

 

 

 

test1.bas 1.67 kB · 0 downloads test1.rom 1.53 kB · 0 downloads

Oh, I see what's wrong..

Last time I cd to the examples folder, I forgot this time so my output ended up elsewhere and I was just running the same old rom over and over.

I've never seen a more glorious background in my life 😄

Edited by Lillapojkenpåön
  • Like 1
  • Haha 1
2 hours ago, Lillapojkenpåön said:

Is DEFINE CHAR a buffered command with limitations similar to intybasic, once per frame etc.?

No, in CVBasic the data is loaded into the VRAM immediately.

 

Ony the sprites are buffered like in IntyBASIC.

  • Thanks 1
  • 2 weeks later...

I'm not used to static arrays, is this an acceptable way to create bullets? There seems to be slight slowdown after all 7 possible bullets are on screen, is that just the emulator, my code or some other restriction?

 

    CONST FALSE = 0
    CONST TRUE = 1
    CONST NOT_IN_USE = 5000

    DIM #bullet_x(7)  : UNSIGNED #bullet_x
    DIM #bullet_y(7)  : UNSIGNED #bullet_y


    FOR temp1 = 0 TO 6
        #bullet_y(temp1) = NOT_IN_USE
        #bullet_x(temp1) = $0000
    NEXT

'------------------------------------------

    'create bullet
    IF CONT1.BUTTON THEN
        IF fire_restrainer = FALSE THEN
            fire_restrainer = TRUE
            FOR temp1 = 0 TO 6
                IF #bullet_y(temp1) = NOT_IN_USE THEN
                    #bullet_y(temp1) = #player_y
                    #bullet_x(temp1) = #player_x
                    'exit loop when free slot is found
                    EXIT FOR
                END IF
            NEXT
        END IF
    ELSE
        fire_restrainer = FALSE
    END IF

    'move bullets
    FOR temp1 = 0 TO 6
        IF #bullet_y(temp1) <> NOT_IN_USE THEN
            #bullet_x(temp1) = #bullet_x(temp1) + $0100
        END IF
    NEXT

    'reset bullet for re-use when offscreen
    FOR temp1 = 0 TO 6
        IF (#bullet_x(temp1) / 256) >= 255 THEN
            #bullet_y(temp1) = NOT_IN_USE
        END IF
    NEXT

    'draw bullets starting with sprite 1
    sprite_nr = 1
    FOR temp1 = 0 TO 6
        IF #bullet_y(temp1) <> NOT_IN_USE THEN
            SPRITE sprite_nr, (#bullet_y(temp1) / 256) - 1, (#bullet_x(temp1) / 256), 0, 10
            sprite_nr = sprite_nr + 1
        ELSE
            SPRITE sprite_nr, 0, 0, 0, 0
            sprite_nr = sprite_nr + 1
        END IF
    NEXT


Also what syntax highlighting does people use when posting basic code on the forum?
 

  • Like 1
20 hours ago, shaoth said:

have you tried to reduce the number of projectiles?
In those days you had to make compromises ;)

I have, there's no slowdown then.. I just really like projectiles 🙂
After compromising as much as I can, and fixing a bug where all bullets collided with all enemies offscreen the slowdown is gone
 

 

 



 

 

Edited by Lillapojkenpåön

I'm having a hard time figuring out why this doesn't copy the sprite frame to the buffer like I want it to

 

        #temp16 = VARPTR player_idle(0)

        #player_buffer(0) = PEEK(#temp16    )
        #player_buffer(1) = PEEK(#temp16 + 1)
        #player_buffer(2) = PEEK(#temp16 + 2)
        #player_buffer(3) = PEEK(#temp16 + 3)
        #player_buffer(4) = PEEK(#temp16 + 4)
        #player_buffer(5) = PEEK(#temp16 + 5)
        #player_buffer(6) = PEEK(#temp16 + 6)
        #player_buffer(7) = PEEK(#temp16 + 7)
        #player_buffer(8) = PEEK(#temp16 + 8)
        #player_buffer(9) = PEEK(#temp16 + 9)
        #player_buffer(10) = PEEK(#temp16 + 10)
        #player_buffer(11) = PEEK(#temp16 + 11)
        #player_buffer(12) = PEEK(#temp16 + 12)
        #player_buffer(13) = PEEK(#temp16 + 13)
        #player_buffer(14) = PEEK(#temp16 + 14)
        #player_buffer(15) = PEEK(#temp16 + 15)

        DEFINE SPRITE 0, 1, VARPTR #player_buffer(0)


All my attempts result in a stripy graphic?

30 minutes ago, Lillapojkenpåön said:

I'm having a hard time figuring out why this doesn't copy the sprite frame to the buffer like I want it to

 

        #temp16 = VARPTR player_idle(0)

        #player_buffer(0) = PEEK(#temp16    )
        #player_buffer(1) = PEEK(#temp16 + 1)
        #player_buffer(2) = PEEK(#temp16 + 2)
        #player_buffer(3) = PEEK(#temp16 + 3)
        #player_buffer(4) = PEEK(#temp16 + 4)
        #player_buffer(5) = PEEK(#temp16 + 5)
        #player_buffer(6) = PEEK(#temp16 + 6)
        #player_buffer(7) = PEEK(#temp16 + 7)
        #player_buffer(8) = PEEK(#temp16 + 8)
        #player_buffer(9) = PEEK(#temp16 + 9)
        #player_buffer(10) = PEEK(#temp16 + 10)
        #player_buffer(11) = PEEK(#temp16 + 11)
        #player_buffer(12) = PEEK(#temp16 + 12)
        #player_buffer(13) = PEEK(#temp16 + 13)
        #player_buffer(14) = PEEK(#temp16 + 14)
        #player_buffer(15) = PEEK(#temp16 + 15)

        DEFINE SPRITE 0, 1, VARPTR #player_buffer(0)


All my attempts result in a stripy graphic?

Try using 8-bit variables instead.  Right now your variables are 16 bit, so in binary for example, it's 0000000011010010 per variable and the Colecovision VDP graphic is 8-bit.  I would recommend using 8-bit variables when possible when the z80 processor is 8-bit. The # in front of the variable name tells it that it is 16-bit, which is same for Intybasic. Removing that will make it 8-bit variable.

Edited by Kiwi
  • Like 1
1 hour ago, Kiwi said:

Try using 8-bit variables instead.  Right now your variables are 16 bit, so in binary for example, it's 0000000011010010 per variable and the Colecovision VDP graphic is 8-bit.  I would recommend using 8-bit variables when possible when the z80 processor is 8-bit. The # in front of the variable name tells it that it is 16-bit, which is same for Intybasic. Removing that will make it 8-bit variable.

Thanks, it's not stripy anymore but the graphic is now only 8 pixels wide instead of 16

EDIT:
Oh!
player_buffer(16) = PEEK(#temp16 + 16)
player_buffer(17) = PEEK(#temp16 + 17)
player_buffer(18) = PEEK(#temp16 + 18)
etc..
is the right side of the graphics, nice!

Edited by Lillapojkenpåön
  • Like 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...