So I tried to make a game and this happened

Basic and Machine Language

Moderator: Moderators

Post Reply
JRBasic
Vic 20 Newbie
Posts: 17
Joined: Thu Dec 20, 2018 10:31 am
Occupation: Programmer

So I tried to make a game and this happened

Post by JRBasic »

So I tried to make a game, but when I tested movement, the character was stuck in place!
Here's the code, It's in CBM prg Studio

Code: Select all

*=$1800 ; starting location is $1800
init
        lda #$0A ; load char J
        sta $1400 ; store into $1400 for later use
        ldx #$00 ; load position
        lda #$93
        jsr $ffd2 ; clean the screen before continuing
start ; done intializing
        lda $1400
        sta $1E00,x ; store into position
        lda #$06
        sta 38400,x ; store blue into color ram
        lda $00C5 ; load value of C5 (keyboard matrix)
        cmp 18 ; compare with 18 (d key)
        beq moveright ; if d is pressed, move right 1 tile
        bne start ; if no key pressed, go back to start label
loop
        jmp loop ; just lock the vic-20
moveright
        inx ; increment x
        lda #$93
        jsr $ffd2 ; and clean the screen so no trail is present
        lda $1400 ; load player character
        sta $1E00,x ; redraw it
        jmp start ; and then return to start lab
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: So I tried to make a game and this happened

Post by srowe »

Your CMP instruction is using a zero page address rather than an immediate value.
JRBasic
Vic 20 Newbie
Posts: 17
Joined: Thu Dec 20, 2018 10:31 am
Occupation: Programmer

Re: So I tried to make a game and this happened

Post by JRBasic »

Didn't think that would work, but thanks!
Moves really fast, though, how do I check if the key is pressed, rather than being held down?
20questions
Vic 20 Hobbyist
Posts: 114
Joined: Sun Mar 10, 2019 7:39 pm
Location: lodi california
Occupation: student

Re: So I tried to make a game and this happened

Post by 20questions »

JRBasic wrote: Fri Jul 12, 2019 9:17 am Didn't think that would work, but thanks!
Moves really fast, though, how do I check if the key is pressed, rather than being held down?
try inkey$, if possible or get a$
Bedroom coder=rock star
modern coder= pop star
i'd rather be a rock star than a pop start 8)
retrojello

Re: So I tried to make a game and this happened

Post by retrojello »

20questions wrote: Thu Jan 02, 2020 4:44 pm
JRBasic wrote: Fri Jul 12, 2019 9:17 am Didn't think that would work, but thanks!
Moves really fast, though, how do I check if the key is pressed, rather than being held down?
try inkey$, if possible or get a$
20questions=idiot
20questions
Vic 20 Hobbyist
Posts: 114
Joined: Sun Mar 10, 2019 7:39 pm
Location: lodi california
Occupation: student

Re: So I tried to make a game and this happened

Post by 20questions »

retrojello wrote: Thu Jan 02, 2020 4:55 pm
20questions wrote: Thu Jan 02, 2020 4:44 pm
JRBasic wrote: Fri Jul 12, 2019 9:17 am Didn't think that would work, but thanks!
Moves really fast, though, how do I check if the key is pressed, rather than being held down?
try inkey$, if possible or get a$
20questions=idiot
what the hell was that for? i'm trying to help. :?:
Bedroom coder=rock star
modern coder= pop star
i'd rather be a rock star than a pop start 8)
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: So I tried to make a game and this happened

Post by Mike »

20questions wrote:what the hell was that for? i'm trying to help. :?:
To put things into perspective: first, you were replying to a question that was already half a year old. Either JRBasic found an answer by himself and just didn't bother to communicate that, or your 'help' was much too late anyhow. Second, your reply referenced a non-existing command (there's no "inkey$" in BASIC V2), but "get a$" (or better, its ML equivalent CHRIN) is probably even the correct answer - by sheer luck.

Main concern about JRBasic's question was: the program "sees" the keys "continuously" pressed when probing address 197, whereas he probably only wanted to move the character once upon the change non-pressed->pressed. Other than using the KERNAL CHRIN call for this, that kind of problem is usually solved by keeping the previous state to indicate whether there was a change, and only then do the desired action.
User avatar
orion70
VICtalian
Posts: 4341
Joined: Thu Feb 02, 2006 4:45 am
Location: Piacenza, Italy
Occupation: Biologist

Re: So I tried to make a game and this happened

Post by orion70 »

Nothing justifies insulting anyone here. I invite members to avoid name calling.
20questions
Vic 20 Hobbyist
Posts: 114
Joined: Sun Mar 10, 2019 7:39 pm
Location: lodi california
Occupation: student

Re: So I tried to make a game and this happened

Post by 20questions »

Mike wrote: Fri Jan 03, 2020 5:48 am
20questions wrote:what the hell was that for? i'm trying to help. :?:
To put things into perspective: first, you were replying to a question that was already half a year old. Either JRBasic found an answer by himself and just didn't bother to communicate that, or your 'help' was much too late anyhow. Second, your reply referenced a non-existing command (there's no "inkey$" in BASIC V2), but "get a$" (or better, its ML equivalent CHRIN) is probably even the correct answer - by sheer luck.

Main concern about JRBasic's question was: the program "sees" the keys "continuously" pressed when probing address 197, whereas he probably only wanted to move the character once upon the change non-pressed->pressed. Other than using the KERNAL CHRIN call for this, that kind of problem is usually solved by keeping the previous state to indicate whether there was a change, and only then do the desired action.
that doesn't justify him calling me an idiot. this is why i rarely help anyone on forums. people are just to unpredictable online.
Bedroom coder=rock star
modern coder= pop star
i'd rather be a rock star than a pop start 8)
User avatar
joshuadenmark
Big Mover
Posts: 1218
Joined: Sat Oct 23, 2010 11:32 am
Location: Fr-Havn, Denmark
Occupation: Service engineer

Re: So I tried to make a game and this happened

Post by joshuadenmark »

We will not tolerate this at all.

retrojello=deleted
Kind regards, Peter.
____________________________________________________
In need of a wiki logon - PM me
User avatar
pixel
Vic 20 Scientist
Posts: 1357
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re: So I tried to make a game and this happened

Post by pixel »

joshuadenmark wrote: Fri Jan 03, 2020 10:17 am We will not tolerate this at all.

retrojello=deleted
Thank you!
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
Post Reply