C64 – Creating a Pac-Clone, Programming Series 5 Update 1 | CBM Prg Studio

Welcome to the PAC Clone series of
creating a Pac Clone video game. This is sort of an in-between video in between
the last video that I did which was Pack Clone five and a final video which I…
the final completed video where the game is actually one hundred percent done which
I’m assuming it’s going to take me sometime probably not going to be until early
next year sometime. Any rate I’m trying to work on the program and a lower pace
and what I did what I was doing originally and I need to take time out to
do other things other rather than, I need to
play some games as opposed to trying to
create this one. But in the meantime I wanted to to go over a few things that I
that I have come across as I’ve been implementing some of the changes as I’ve
gone forward I’ve come across a couple of things and I want to share that with
you. This video is intended for aspiring programmers or people with a technical
background and I don’t think anyone who doesn’t have that sort of a background
would really be interested in in watching this video. This video contains
spoilers if you would rather not see some of the developments as I am going
here, this video contains a few spoilers so be forewarned and turn the video off
at this point if you do not want to see those spoilers. It is it is a pretty
technical video and I’m sorry about that but it is a video about creating a
Pac-Clone video game, and I do cover techniques and assembly language and
using the CBM program studio so sit back and enjoy. Okay, so in this segment I’m
going to talk about a little effect that I was trying to build into to my version of this Pac-Clone even
though it doesn’t really show up in the any version I’ve ever seen and that was
to make one, like a transition one map drawn into the other and so I’ll show
you what I’m talking about here in a moment. I have this subroutine to draw the map,
you know to draw the Pac-man map on the screen and then I have what I started
with is the second routine that would draw… to redraw the map but with the different
map coming up from bottom to top and let me run that to see, so you can see
what it is and I’m talking about. So there it is it’s kind of slow… and I’ll
go over how that works really quick here. Let’s run
that again… what I did here is I have this program code
it’s going one line at a time for 40 characters, take this second line and…
basically copy the second line paste it into the line above it does it
all the way down to the bottom…copy that bottom line paste it in on the line right above it
but then at the very bottom I have a quick little loop that draws in the new
map it just puts so replaces that bottom line so that as it goes it’s
painting something in, and right now it’s the same map on this version. So I was
trying to play with that and then I came up with a different version of that, say
why, why reinvent the wheel of the drawn draw map, just redrawn, why not just, redraw the map but change the
map pointer the low and high as you draw just call it over and over again
seems highly inefficient but I thought I’d give it a try so I want to show you
what that turns out looking like So I’ll comment out the other one and comment
this one in. And you can see, I didn’t bother yet to put this in a loop. So I just call it 25
times and let’s run that, one function call move
the screen one, once, one position. one row the time so you see I don’t know if you could
tell on the video, let me run that again it’s really jaggedy coming up. Again. It does the trick,
you know it draws but even in emulation it draws really
quirky. but it’s a more succinct and clearer way of
doing but because it’s so jaggedy, I opted not to
use that. I then went ahead and redesigned and went with a fourth version
I want to show you, uncomment that, and before I
run that… take a look at the code…. And in this version I figured why not just
copy from basically from the line one line below “428” is the second line, the
second row on the screen and then paste it in at “400” which is the top line on the
map and do the same thing with the color memory which are these memory values and then
do it all for two hundred and fifty five times, just loop it, and then doing
that for “400” for “500” for “600” and for “700” this
turns out to be really fast. A lot more faster than the other two
methods and as I’m going here I’m doing the
color values you’ll see here and at the bottom the same sort of thing where it
has to bring in the new row for 40 characters so at the very bottom of the
screen here at “7c0”, last row of the 25 rows on the Commodore 64, the last
row, it’s bringing in the color value and it’s bringing in the data for 40 characters as
it goes so let’s see what that looks like and you see it’s much faster, it comes up
and I have my color values in there and I’ve also, spoil alert here I’ve also
changed the dot pattern a little bit. I was trying to make it such that it would, you
could follow, you could follow a certain, you know you could just follow the dots and clear the
dots a little easier that way rather than having to go into every little nook and corner of the whole
map and I might tweak it even further but this is where I’m at right now with it.
Let’s run that again to see how that looks And this is full-speed, there um, I was thinking
I was gonna have to slow it down but when it when it didn’t have the color values
in there when I… if I were to comment out all of the… If I were to comment out these
two lines these two lines on all the color value areas it runs a lot faster. So I thought I
would have to delay in but the way it looks now, I like that speed so I was
thinking I would maybe have the effect going from down to up and maybe from up
to down when you clear a map level it was just an idea, I do plan on implementing
that. I also had the idea of maybe throwing the effect in where it shakes, moves up and down, moves
up and then down just to make it look like something happened, you ate all four monsters or whatever,
but that was that was an idea I had. I don’t know if
I am going to implement that. So that’s… that’s it for this segment on
the little effect of drawing the map in a different fashion. I do want to bring up the screen
designer that’s built into CBM program Studio. This is a fantastic tool. You can
either go into it from the Tools menu and then to the screen editor which will
bring you into a blank palette or you can open up the one that you’ve already
designed and saved which is down here in the bottom left under screen designs, which
I am going to pull up and, in here you have your colors right here,
defaulted into draw mode… and for example if I were to go down to where
that period is to dot, which is I believe character 46, and if I use the left mouse click anywhere
on the screen it draws the dot. If use the right
mouse click uses the erase color and erases so I
can put in so I can put in dots and erase them. But the thing that I noticed when I was doing that draw map function I
really wanted to know what these positions were and as you move your mouse
you see on the bottom the base address down here the base address, the character
address, these values change as you move the mouse so here at the bottom left corner
you can see where I got that “DBC0” for the color value and the “07C0” so
this is actually very useful it helps, it helps me to determine where all the power pills are, the exact positions
so I can just write those values down, as I move the mouse write it down and record
that information and now that I’ve added a
couple of maps I’ll show you what those look like so far what I’m, what I’ve worked
on. Down here it shows that I have four maps, I’ll show
a couple of those. If I hitting next, you see the difference there, the color change
what I decided to do was to keep the… for simplicity just keep the ghost
cage in the same location and the warp tunnels in the same location and then on the 3rd
map it’s the same as a second one, I do intend to probably change that and the fourth
map I’m going to leave for a surprise, but this is a very useful tool and I
know I covered this in a prior video but it is, it’s, it’s, it’s fun to me and so I
think it’s cool to, to share that. When you go to export it, you hit export assembler
File export assembler, and what I’ve been doing now is exporting it not, not to a file
but just into memory exporting the color data, and coming down
here adding the description generating the empty rows and generate the whole row trailing spaces, when you do that, it generates
this whole thing, it inputs comments on the screen with your… what you named your map. I named it map 1 map 2 map 3. So it’s very, very, very useful is very
fun to design your screens this way. You also have the ability here to grow in
your grid, which throws in those grid lines. and it’s a highly useful tool and I highly,
highly, recommend it, it’s very fun I wish I would have had this, this tool back in the 80’s,
or early 90’s This would have been really fun to play with
and it still is. This is a great tool. Okay, so in the previous segment I was talking
about how cool the screen designer is. In this segment
I wanted to talk about the sprite editor, which you can get to from, in CBM Program studio
from tools, sprite editor, and you start out with a blank palette
or you can go directly in to your sprite… saved version
of the sprite editor where I have all my sprites and you can see here I’m up to now I’m up to 31 sprites which is a lot but the reason is
for the animation. So you can see I have my up facing, my downward facing, left
facing, right facing, and then I have the ghosts, I’ll expand them. What I was trying to get at, and I still haven’t
removed the frown yet, I don’t know if I will. Lower on the list of priorities for this program. So I needed a way… I needed a death animation.
and that’s what I did, I directly ripped off or copied the way they do it on Pac-Man. So when you
die, no matter which direction you are facing,
they put you to facing up, and then you slowly kind
of deteriorate as the music plays. So that’s
my little animation. I’ll show you what that
looks like if you run this from 21 to 31, down here,
just put that in. That’s kind of what that looks like. So…
Slow it down a little. And it looks a little different than Pac-Man
this is only an 8×8 grid so this is what I had to work with and this is this is a very, very, useful tool,
this sprite editor and it’s terrific to use. So on the same way you can export your
screen data you can also export your sprite data by going up here file, export
to preview, assembly data, generate using three… three values per line, pad your data
to 64 bytes, decimal or hexadecimal and then generate only included sprites or ALL sprites, so
there’s a checkbox for that, include in generation right here, so if you uncheck that it won’t
export as part of this. And then you can just copy that
to the clipboard, paste it into program and you’re off and running. So that’s where I’m at with animating the
Pac-Clone death. So in this segment i want to talk about a method of creating a sound effect that I
stumbled across believe I saw it on Lemon 64 it was on a forum or one of the posts someone
created they said just start off with this line of…
These two lines of code and it was an LDA
and an STA. LDA a number stored it in 54296 and then
load a zero and store it in 54296 which even now I don’t even know what that does but
we’ll go into that in a minutes, but what this does is this creates a sound and then it turns it off and then
if you don’t throw a delay in between then you don’t hear anything, no effect so what I decided was to
try to put this effect in as you’re eating the dots and so I’m going to show
you what that sounds like and for now until I get some better and this is all…
I know nothing about sound, sound effects This is the effect I’m going to use until
I have something better. I did stumble across a website which is a Commodore 64 memory map. And in here 54296 is “D418” so
let’s look at that. Volume and filter modes, so that’s… this
is the memory map, this this little memory map is very useful it shows you all the things are mapped in
the memory of the Commodore 64 and it can come in handy, and has a lot for me already.
So let me… enough about that let me run this. You’re going to notice that I’ve
implemented flashing energizers once I run this that’s pretty much all you can
see in the sound effect. I thought it was better than nothing, but
I’m not 100% satisfied with it, I just just wanted
to show you how I created that sound effect. If you want I’ll show you a death, of what
my animation looks like in game, check this out. Boom… Alright so that’s the sound effect you
saw the flashing power energizers and death animation in effect. In this segment
I wanted to go back to a discussion that I had a little bit in the last video regarding
program interrupts. I got myself into a little bit of trouble using the
interrupt and you might be saying how can you get in
trouble using your interrupts. Well you can get into trouble with your
interrupt if you… if your main program ends up stepping on things that your interrupt
is using and vice versa, so that’s exactly what happened with my interrupt.
As I was making the energizers flash they’re using the zero page memory
“FD” and “FE”, but I was also using “FD” and “FE” inside the main program. I use it for things such as
drawing the map. So right here, I have since switched it to
“FB” and “FC” across the board and that’s why this is a little more expanded… a little… it’s
much more succinct the way it was before when I had
“FB”, “FC”, “FD”, “FE” but because the interrupt was also using the
same variables what would happen was… just some weird things like in between levels
the colors would just go all wacky. You can be going along eating the dots and then the dot’s wouldn’t
erase, it would just stay there but it would be counted as… You get points for it. So
just weird little quirky things like that. So I wanted to throw that caution
out there when you’re using interrupts be careful not to step on your main program data. I know it’s
more of a complex issue when, but you’re using these variables “FB”, “FC” and your using that in
your main program but you’re also using “FB” and “FC” for example
in your interrupts and they continuously updated the background
while the programs running so you end up with kind of random data. That be a problem and it’s a word of

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,


  • TechLord79 says:

    Hmm I don't have the skills to judge, would the VIC-II scrolling feature/register $D011 have helped? ($D016 is for horizontal)
    But looks complicated 🙁 http://www.0xc64.com/2013/11/24/1×1-smooth-text-scroller/

  • Retro gameplays says:

    I am allergic to trailing spaces in source code and you have plenty of them.


Leave a Reply

Your email address will not be published. Required fields are marked *