Link6415 Posted October 3, 2015 Share Posted October 3, 2015 Hello. I am currently working on an RPG for the beloved Commodore 64. I will share more, but I need to know how to put my charset at $E000 from a BASIC prg. A LISTing would be excellent, but an explanation would be okay too (although I will have a lot of questions.) After I get this in, I'll have more to show and tell. Quote Link to comment Share on other sites More sharing options...
TMR Posted October 3, 2015 Share Posted October 3, 2015 I will share more, but I need to know how to put my charset at $E000 from a BASIC prg. A LISTing would be excellent, but an explanation would be okay too (although I will have a lot of questions.) The problem there is that you'll need to move the screen RAM as well, character sets and screens have to exist in the same 16K video bank... and BASIC will need to be told that the screen is no longer at 1024 as well if you're relying on PRINT commands. To switch to video bank 3 ($c000 upwards): poke56576,196 To select $c000 for screen memory and $e000 for character set: poke53272,8 To get BASIC talking to the $c000 screen: poke648,192 If you run/stop and restore the machine it won't revert to the standard $0400 screen, so poke648,4 is needed to get the cursor back to the right place. 1 Quote Link to comment Share on other sites More sharing options...
Link6415 Posted October 3, 2015 Author Share Posted October 3, 2015 Ok. Good news: Got the tiles at $E000 Bad news: I may have forgotten 1 teensy weensy detail in my first post. I'm using bitmap mode. Quote Link to comment Share on other sites More sharing options...
7800fan Posted October 4, 2015 Share Posted October 4, 2015 it has been a while since I've dabbled into BASIC bitmapped screen but when you're in bitmap, memory location 1024-2023 is still used for setting colors. I've become too dependent on Super Expander for ez graphics on my 64. Quote Link to comment Share on other sites More sharing options...
Link6415 Posted October 4, 2015 Author Share Posted October 4, 2015 Sorry if this is not the conventional way of posting images on this forum. Things are a little different over on Lemon. I am a noob here. Okay, the first pic is the listing of the program i used to put the charset in memory. The file used LOADed was exported from Charpad. Is everything good here? The second pic shows the tiles, sucessfully POKEd onto the screen. The third pic shows the listing of the program i used to test out bitmap mode. This is where I think I messed myself over. Is everything good here? The fourth pic shows the result of my bitmap demo. Hm. Something seems to be amiss. I'm confused. Is the problem because I don't understand bitmap mode, or did I mess up the program that puts the charset in memory?!? Ima confuzzled kid and i need helps plz. Quote Link to comment Share on other sites More sharing options...
Link6415 Posted October 4, 2015 Author Share Posted October 4, 2015 Aha! There was a mistake! Line 7 should be 7 POKE BSET,PEEK(BSET)OR32 Okay, the bitmap works, but isn't turning off correctly... Hmm. I'm going to eat breakfast and then maybe I can figure this out... Quote Link to comment Share on other sites More sharing options...
TMR Posted October 5, 2015 Share Posted October 5, 2015 I may have forgotten 1 teensy weensy detail in my first post. I'm using bitmap mode. Bitmap mode... from BASIC? Is there any reason why you're going down that route rather than using faster, easier to manipulate character-based graphics? Quote Link to comment Share on other sites More sharing options...
Link6415 Posted October 5, 2015 Author Share Posted October 5, 2015 Nonononono no. I'm only using BASIC to test out my charset and make sure I can still access the bitmap. Although I may use a combination of ML and BASIC for the final. But, I still need to get this bitmap thing figured out. Quote Link to comment Share on other sites More sharing options...
TMR Posted October 6, 2015 Share Posted October 6, 2015 I'm only using BASIC to test out my charset and make sure I can still access the bitmap. Although I may use a combination of ML and BASIC for the final. But, I still need to get this bitmap thing figured out. Okay, that sounds a bit more viable although i'd still advise using characters for speed and memory reasons personally. The BASIC program in that screenshot is using a base address of $2000 (bank 0) for the bitmap and putting the colour at $c000 (bank 3) - that won't work, both need to be in the same 16K bank. Bitmaps in bank 3 can be at $c000 or $e000 with the latter being easier to work with. i'm not awake yet, but remove lines 6 and 7, replace them with the POKEs i gave you, set base to 57344 ($e000) in line 3 and try that? Quote Link to comment Share on other sites More sharing options...
Link6415 Posted October 6, 2015 Author Share Posted October 6, 2015 Thanks! Quote Link to comment Share on other sites More sharing options...
Link6415 Posted October 6, 2015 Author Share Posted October 6, 2015 (edited) Wait, POKEs you gave me? POKE 56576,196 and POKE 53272? I put those in the program to load in the charset. It wouldn't work without them. And won't putting the bitmap at $E000 overwrite the char data? I need it, to draw the tiles on the bitmap! The bitmap works correctly. But I am getting the same result when stopping the program as before (see the fourth picture). I removed line 21 and the bitmap turned off, but the chars were random lines and dots! Edited October 6, 2015 by Link6415 Quote Link to comment Share on other sites More sharing options...
TMR Posted October 7, 2015 Share Posted October 7, 2015 Wait, POKEs you gave me? POKE 56576,196 and POKE 53272? I put those in the program to load in the charset. It wouldn't work without them.They also works for the bitmap. 53272 sets screen and character position but those become the colour RAM and bitmap pointer when using bitmap mode. 56576 sets the VIC-II bank, in this case bank 3 which is $c000 to $ffff. And won't putting the bitmap at $E000 overwrite the char data? I need it, to draw the tiles on the bitmap! Since you can't read from $e000 with BASIC (and need to disable the ROM there and BASIC's ROM to do so from assembly language) it'd be sensible to instead move the characters down to somewhere you can get at them like $c800 - you can then read from the characters and write to $e000 or switch to using character-based graphics with the screen at $c000 and the characters at $c800 The bitmap works correctly. But I am getting the same result when stopping the program as before (see the fourth picture). I removed line 21 and the bitmap turned off, but the chars were random lines and dots! You've added changes i suggested to 648 amd 56576 at the start of your program so you'll need to restore the original values at the end as well (which are 4 and 199 respectively) otherwise it dumps out to a text-based display but still in bank 3 where there's no ROM character set. 1 Quote Link to comment Share on other sites More sharing options...
Link6415 Posted October 7, 2015 Author Share Posted October 7, 2015 Sounds good. The original program that loaded the charest loaded it to $c800 so that will be easy - I'll just switch out the programs. Then I'll add your changes to the bitmap program and we'll see what happens. I won't be able to get anything done till the evening, I'll try then. Thanks! Quote Link to comment Share on other sites More sharing options...
Link6415 Posted October 8, 2015 Author Share Posted October 8, 2015 (edited) Yes! Everything is working! The bitmap turns on correctly, does what it's supposed to, and turns off correctly, bringing me back to text mode.I played around with your pokes, is the listing okay? Edited October 8, 2015 by Link6415 Quote Link to comment Share on other sites More sharing options...
TMR Posted October 8, 2015 Share Posted October 8, 2015 I played around with your pokes, is the listing okay? i can't see any references to 56576 to change video banks back and forth...? There's a little redundancy; line 4 sets BLOC to V+24 (where V is 53248) but that comes out as 53272 so you can either remove like 4 or change lines 7 and 20 to use BLOC instead of the direct value. Quote Link to comment Share on other sites More sharing options...
Link6415 Posted October 8, 2015 Author Share Posted October 8, 2015 I just woke up and didn't notice a couple of those things. 56576 was turning the chars into confetti when I turned off the bitmap, so I took it out. The program works though. Quote Link to comment Share on other sites More sharing options...
Link6415 Posted October 8, 2015 Author Share Posted October 8, 2015 Weird things are happening all over the place. SAVE "@:BITMAPDEMO",8,1 saves a program CALLED "@BITMAPDEMO"!!! WTF! Ugh. There is one last option. I think I can store the "char" data in an unused area in memory. It won't actually be for the chars, the real charset will be in the default area and remain unchanged. When I want to plot tiles or "chars" on the bitmap, I won't read the data from the character memory, I'll read it from the unused area in memory where I put the "charset". Hmm. That sounds good, actually. What do you think? Does that sound like a feasible solution? Quote Link to comment Share on other sites More sharing options...
Link6415 Posted October 8, 2015 Author Share Posted October 8, 2015 And what would the best unused area in memory be? How do I put char data there? Quote Link to comment Share on other sites More sharing options...
TMR Posted October 9, 2015 Share Posted October 9, 2015 56576 was turning the chars into confetti when I turned off the bitmap, so I took it out. The program works though. Like i said, you need to set it back when exiting as well or you leave the machine in the wrong video bank. If you don't set it at the start you're writing to the bitmap at $e000 in the program but the VIC-II is displaying the one at $2000. I think I can store the "char" data in an unused area in memory. It won't actually be for the chars, the real charset will be in the default area and remain unchanged. When I want to plot tiles or "chars" on the bitmap, I won't read the data from the character memory, I'll read it from the unused area in memory where I put the "charset". i'm not sure why you'd want to do that if the characters are already going to be in memory once at $c800? And what would the best unused area in memory be? How do I put char data there? BASIC programs run $0801 to $9fff, BASIC ROM is at $a000 to $bfff, $c000 to $cfff is free, I/O sits $d000 to $dfff and Kernel ROM is $e000 onwards - only the first and third of those spaces is available to read from with BASIC (you can write to all of them except the I/O space) and you lose space for your program with the first. You can turn ROMs off to get at what's under them from assembly language. Quote Link to comment Share on other sites More sharing options...
carlsson Posted October 9, 2015 Share Posted October 9, 2015 Remember the screen matrix really is just 1024 bytes, so $C000 - $C3FF. That would leave you with another 3K between $C400 - $CFFF to store character definitions, possibly an alternative bitmap colour screen and then have the actual bitmap data at $E000 that is writable, but not easily readable. Did I understand you correctly that you will plot characters in place in bitmap mode? In that case, remember the organization of graphics data is different, in such way in bitmap mode you plot one row of 8 pixels * 40 columns, then next row of 8 pixels * 40 columns, while character data obviously are 8 pixels * 8 rows (bytes) right away. A simple *40 will solve that though. Quote Link to comment Share on other sites More sharing options...
Link6415 Posted October 9, 2015 Author Share Posted October 9, 2015 PFFF! Okay, I made a few assumptions. The "strange things" were just me being tired because I was working on this at 4 AM. If you look at my post, I put "@BITMAPDEMO". That is exactly how I typed it. (Is there a facepalm smiley?). If you didn't notice, it should have been "@:BITMAPDEMO". The other thing that I found weird was the result of using caps in a REM. *sigh* (Upon flipping through my C64 system guide, I realized my mistake.) Anyway, I'm just going to proceed with the original plan. Thanks for the help, it may come in handy if I run into a REAL problem. Quote Link to comment Share on other sites More sharing options...
Link6415 Posted October 11, 2015 Author Share Posted October 11, 2015 Well I think this was the final straw. I can't PEEK the char data. There's too many problems with this, and nice scrolling isn't necessary for an rpg anyway. I think I'll just use char mode. Quote Link to comment Share on other sites More sharing options...
TMR Posted October 12, 2015 Share Posted October 12, 2015 Well I think this was the final straw. I can't PEEK the char data. There's too many problems with this, and nice scrolling isn't necessary for an rpg anyway. I think I'll just use char mode. You can PEEK the character data if it's at $c800 but not when it's under the ROMs. But nice scrolling would usually mean character-based graphics anyway; trying to even double buffer shift a bitmap in assembly language isn't exactly something i'd recommend for a beginner. Quote Link to comment Share on other sites More sharing options...
Link6415 Posted October 13, 2015 Author Share Posted October 13, 2015 How does character scrolling work exactly? Quote Link to comment Share on other sites More sharing options...
carlsson Posted October 13, 2015 Share Posted October 13, 2015 Horizontal scrolling is done through the VIC-II register at 53270, ideally by setting the display to 38 columns so you get one hidden column on each side of the screen. FOR I=199 TO 192 STEP -1:POKE 53270,I:NEXT Then you make a hard copy of the screen shifted one character to the left (possibly using double buffered screen matrix, so you shift between them with POKE 53272), copy the next content into the rightmost column and scroll again. This means the VIC-II does the soft scrolling for you. It will work in hires mode too, but instead of copying up to 37*25 cells = 925 bytes + inserting another 25 bytes of new character data, you'd be copying the bitmap data of 37*8*25 = 7400 bytes + inserting another 25*8 = 200 bytes of new data. If only a small portion of the bitmap needs to scroll, less data needs to be moved but then you also need to use raster interrupt to time it properly so you only change the value of 53270 during the desired raster lines. Of course this is the same if you work with character mode so it may already be part of the plan. Anyway, wouldn't a RPG contain very much repeated graphics: walls, doors, objects, monsters anyway which are more handy to use in character mode than going through bitmap mode where you have to plot each pixel individually? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.