Page 1 of 1

Most basic graphical assembley language game

Posted: Fri Dec 27, 2019 2:25 pm
by RetrogamerRhys
I was thinking what would be one of the most basic games a newbie like me could program on the Commodore 64 using assembler with maybe BASIC elements. I was thinking about a Pong clone or maybe a guide the dot to another dot game? Any ideas? Thanks.

Re: Most basic graphical assembley language game

Posted: Fri Dec 27, 2019 5:17 pm
by EvilSandwich
Pretty much the only thing you need to do to make just about any game are two main subroutines:

1) Initializing all the assets. Like how big the paddles are, where the ball starts, how the ball will move before you do anything to the game, etc and telling the game where all these value will be stored in memory.

2) The Main Loop. This where the game runs the majority of the time, waiting for your input. It's literally just an endless loop that just continues forever until something happens, like you telling the paddle to move, the ball hitting the paddle, the ball hitting the walls, etc. As it loops, it'll call different subroutines to check if you did anything or if any status need to be applied.

I'm in the process of writing a dirt simple 2D platforming engine and here's an example from my gravity test version.

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; initializing Physics test position, dot color and first spawn
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

LDX #$02 	;setting high and low byte of spawn
STX $02
LDX #$08
STX $01

LDA #$01 	;setting color

STA ($01),y	;spawning dot


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Main Loop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

mainloop:
JSR gravity
JSR applymomentum ;Empty for now
JSR checkcollision ;Empty for now
JSR readkeys	   ;Empty for now
JMP mainloop
All this does so far is spawn a dot and run it through some conditions.

1) Spawn Dot
2) Start Loop
a. Is it in the air? If yes, make it fall.
b. Was it being moved forward from a previous loop? If yes, push it forward.
c. Did it hit anything? If yes, stop it from moving.
d. Did the player push a button? If yes:
i. What button did they push?
ii. What does that button do?
iii. Do what the button does.
e. Restart Loop with new conditions.

You can literally put anything into the main loop, heck if you're just doing a Demoscene you don't even need a subroutine for accepting user input. But the loop ITSELF needs to be in place. Without it, the program will literally do only ONE THING then exit.

So to summarize: the 100% bare minimum a game needs is two main subroutines.

1) Define "Stuff"
2) Do Stuff, then loop back and do more Stuff.

Re: Most basic graphical assembley language game

Posted: Fri Dec 27, 2019 7:03 pm
by RetrogamerRhys
Hi will the code you published work straight in assembler for producing a dot on the screen? As I am unsure of the memory locations you need to write to in Assembler or POKE in Basic. It would be nice to have a tutorial of how to integrate assembley into Basic programs and how to call assembley subroutines etc. Thanks for the code I will try it.

Re: Most basic graphical assembley language game

Posted: Fri Dec 27, 2019 7:11 pm
by EvilSandwich
Oh good lord no. That's not C64 code at all. The C64 won't know what to do with it.

I just posted it as an example. The subroutines those calls go to aren't even included.

Re: Most basic graphical assembley language game

Posted: Fri Dec 27, 2019 11:46 pm
by akuyou
I think you're going to be best taking a look at my simple samples... There's a tutorial on how to get a bitmap smiley on the screen here:

https://www.chibiakumas.com/6502/simple ... p#LessonS2

Lesson S11 will add Joypad reading, but the video hasn't been recorded yet!!!

Re: Most basic graphical assembley language game

Posted: Sat Dec 28, 2019 12:10 am
by EvilSandwich
Oooo, looking forward to the joystick one. I the joystick ports are crazy weird between the player 1 and 2 ports.

Re: Most basic graphical assembley language game

Posted: Tue Dec 31, 2019 2:23 pm
by Strela_999
Oh, thanks for the joystick tutorial, I was aiming at coding something for the Master System, but if I can port my stuff on PC, it'd be cool to be able to use a joystick.
Plus, it looks simple enough so that I can do it while writing a market analysis based on some villas for sale in Athens, which I'll have to do by mid February, because work won't understand that I want to code game for a decades-old console!

Re: Most basic graphical assembley language game

Posted: Tue Dec 31, 2019 4:36 pm
by RetrogamerRhys
Does anyone have a tutorial on how to save their work to a 5.25inch disk using a 1541-II Floppy Disk Drive from 64Mon (the assembler I am using). I have a formated disk ready. I do recall reading how use the dsave command but I am unsure. I want to be able to save a PRG file after I've finished coding aswell.
Thanks