C64 BASIC
StevenVI

Well, this is for any programming-related topic, right? Good, here's my C64 trouble.
I'm trying to make a Pong clone with the regular text mode on a standard C64, nothing big or fancy (I'm too lazy to mess with determining an angle for it to bounce off the paddle with in a graphics mode). It's just about done, the only problem is with POKEing to the screen after text has been displayed. It works fine, the ball is displayed in the right place until it goes off-screen and says 'Player 1/2 score'. After it does that and space is hit to continue, the POKE commands don't update the screen anymore. I've already checked through, it's not because I accidently took it out of the loop for that. It's happened in other programs, too. The only way to make it work again is by restoring the display (RUN/STOP + RESTORE) and running the program again. It's pretty confusing... if anyone still has one of these things hooked up (I'm probably wasting my time asking this :P) could you verify if this works? A simple example that won't work for me is:
10 PRINT "{CLR/HOME}": REM PRESS SHIFT AND THE BUTTON NAMED IN BRACKETS
20 PRINT "BOUNCING BALL"
30 X = 1: Y = 1
40 DX = 1: DY = 1
50 POKE 1024 + OX + 40*OY, 32
55 POKE 1024 + X + 40*Y, 81
57 OX = X
60 X = X + DX
70 IF X <= 0 OR X >= 39 THEN DX = -DX
75 OY = Y
80 Y = Y + DY
90 IF Y <= 0 OR Y >= 25 THEN DY = -DY
100 GOTO 50
I apologize if that's too much to type up on a C64 keyboard :P. But anyways, a program like this won't work on my C64... should I go back to the resale shop and buy that other one they had with the snipped cord that cost more (resale people aren't the brightest ;)?
A side note, notice how a color (:) is the way of saying go to the next line in BASIC and a semicolon (;) in C? Both of them don't need to have shift hit to use them, I wonder if it was originally supposed to be a colon, but whoever made it wasn't familiar with a PC keyboard. I dunno... probably not, I'm just blabbing now...

Matthew Leverton

This code looks fine from a glance; what does it do for you? I can try it on my C64 later tonight. I still have it hooked up; it brings back my childhood. :) It looks quite comical sitting next to my two PCs and my dreamcast.
--
Matthew Leverton - matthew.leverton@interclay.com

StevenVI

Well, it appears to do nothing, but I know it does something, cause when you hit RUN/STOP it displays the ball if it's stopped at the right part, but (obviously) ends the program. I'm wondering if my C64 is just messed up somehow or what... it is a bit old after all... :P. I wish I had a disk drive, so I could save my PONG program... but oh well... it's been sitting on for a while now :P.

Matthew Leverton

short response cuz i'm using my dreamcast without a keyboard...

change "25" to "24" in line 90

llyod

Possibly the reason is the DX = -DX thing. If is X < 0 then the char plotter will poke into memory BEFORE screenmemory, and that's stack I think, so it'll mess up.

Regards,
Zerius

Ahhhh Penis

U got a dreamcast too? They r kewl, but I there should be more multiplayer (over internet) games for them. U got soulcalibur or house of the dead 2? Kewl games. Anyway, seeing this has nothing to do with game programming at all and will not achieve anything, I wont make this message too long.
Useless as ever>> Palyndrome

Matthew Leverton

Possibly the reason is the DX = -DX thing. If is X < 0 then the char plotter will poke into memory BEFORE screenmemory, and that's stack I think, so it'll mess up.
Nope, that's fine. He is initializing the X and Y, and he prevents it from going below zero because he switches the direction of DX anytime the ball "hits" the edge of the screen.
The problem is that there are only 25 vertical lines, and he is accessing 26. (0-25) I'm not sure what comes after the screen memory (1024-2023), but it killed the listing of the program when I POKEd out of bounds.
Other than that, I tested the program as listed, and it worked fine.
I did add/change a couple of lines afterwords:
25 C = 32
50 POKE 1024 + OX + 40*OY, C
52 C = PEEK(1024 + X + 40*Y)
This lets the screen "remember" what character was originally there.
--
Matthew Leverton - matthew.leverton@interclay.com

StevenVI

Okay, I think that I did have 24 in my program, hold on, I'm gonna go check... okay, yeah, I had it at being 24 for the bounds of the y axis. Type-o in the original thing. Okay, here's my main problem, though. My program works fine until it displays text to the screen, then it decides that it doesn't like the POKE command anymore. It's really confusing... I should just mail one of you guys my C64 and have you ness with it :P. If I only had a disk drive to save with now... heh...

...I think I'm gonna go screw with it... maybe I'll write up all the source for my game on the computer so you guys can see exactly what's going on with it, although I doubt it would work, if the sample code that I posted works fine for everyone else...

StevenVI

Okay, I messed around with it... I narrowed down the reason it doesn't display the ball to the PRINT "{CLR/HOME}" function/whatever you'd call it. I noticed that my demo didn't mimic what happened in my program exactly... some oughtta give me a nice hard kick. Okay, from step one again here... it prints text to the screen saying which player scored, the the screen is then cleared once the player hits spacebar. The main loop is called again, and the ball does not display. When the PRINT "{CLR/HOME}" lines are REMed out, the ball displays everywhere it's supposed to. I downloaded an emulator... I should probably re-type all the code onto there to see it it works...

Thread #149512. Printed from Allegro.cc