IuriNery Posted May 24, 2019 Share Posted May 24, 2019 Hello everyone, I'm working on a project and I have a few questions: First, take a look into this code: ; Kernel ; ------Kernel STA WSYNC LDA INTIM BNE Kernel ; Turn ON Display STA VBLANK LDX #48KernelLoop ; Preload Colors LDA Screen_1_BKColor-1,X LDY Screen_1_PFColor-1,X ; BK/PF Colors STA WSYNC STA COLUBK STY COLUPF ; Draw Playfield LDA Screen_1_PF0-1,X STA PF0 LDA Screen_1_PF1-1,X STA PF1 LDA Screen_1_PF2-1,X STA PF2 ; Skip Lines STA WSYNC STA WSYNC STA WSYNC DEX BNE KernelLoop RTS As you can see, I'm loading X with #48, because the shape & color tables have 48 values each, this is the result: Now to the questions: 1. If I use #96 instead of #48, how do I update the Playfield only every 2 values? (What I'm trying to ask here is how do I modify the #48 and use #96 but still get the same results? So I can draw sprites using the #96 loop). 2. Is it still possible to draw sprites (Player/Ball) using that amount of resources in the Kernel? (Updating the PF & BK like in the code above). Thank you. Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted May 24, 2019 Share Posted May 24, 2019 I think this is what you're asking for. Have you seen my Collect tutorial? LDX #96 KernelLoop ; Preload Colors LDA Screen_1_BKColor-1,X LDY Screen_1_PFColor-1,X ; BK/PF Colors STA WSYNC STA COLUBK STY COLUPF ; Draw Playfield LDA Screen_1_PF0-1,X STA PF0 LDA Screen_1_PF1-1,X STA PF1 LDA Screen_1_PF2-1,X STA PF2 ; Skip Lines STA WSYNC DEX BNE KernelLoop RTS Quote Link to comment Share on other sites More sharing options...
IuriNery Posted May 24, 2019 Author Share Posted May 24, 2019 Hi, Yes, I'm actually studying your tutorial, very good, I'm trying to get the player sprite show in the Playfield, but it's a little complicated, I don't think it's possible using this Kernel that I'm using without some heavy modifications I guess. I tried your code, like this: But this is the result: My guess is that the program is trying to access values from the table that are not there? (The tables have only 48 values). What I want is to draw the PF in a #96 loop, but using tables that have 48 values, is this even possible? Maybe using a variable to store the kernel loops? Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted May 24, 2019 Share Posted May 24, 2019 What I want is to draw the PF in a #96 loop, but using tables that have 48 values, is this even possible? Maybe using a variable to store the kernel loops? That's similar to what I do in Collect. I use Y to control the loop, and a RAM value called ArenaIndex that's loaded into X when it's time to draw the playfield. Quote Link to comment Share on other sites More sharing options...
IuriNery Posted May 24, 2019 Author Share Posted May 24, 2019 That's similar to what I do in Collect. I use Y to control the loop, and a RAM value called ArenaIndex that's loaded into X when it's time to draw the playfield. The problem is that I'm using Y for the PF Color, maybe I should make use of some variables... If I understand correctly reading the tutorials, the Player sprites should be draw at the same time as the Playfields/Background? So that way you can control the X/Y position of the sprite, right? So, this is actually impossible to do? JSR Kernel (draw the PF etc.) JSR DrawSprites (draw the player) Quote Link to comment Share on other sites More sharing options...
JeremiahK Posted May 24, 2019 Share Posted May 24, 2019 (edited) Instead of using X for the line counter, you could store it in RAM. To decrement it, use DEC instead of DEX: LDA #96 STA $90 ; This is in RAM. It should be replaced with a label, so its less confusing. ; I havent seen your RAM variables, so this address might already be used somewhere else in your code. KernelLoop ; Preload Colors LDX $90 LDA Screen_1_BKColor-1,X LDY Screen_1_PFColor-1,X ; BK/PF Colors STA WSYNC STA COLUBK STY COLUPF ; Prepare X for playfield LDA $90 ; First, load A with the line counter (1-96) LSR ; This divides A by 2... TAX ; ...and then transfers the result to X (1-48) ; Draw Playfield LDA Screen_1_PF0-1,X STA PF0 LDA Screen_1_PF1-1,X STA PF1 LDA Screen_1_PF2-1,X STA PF2 ; Skip Lines STA WSYNC DEC $90 ; Decrement the line counter BNE KernelLoop RTS Edited May 24, 2019 by JeremiahK Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted May 24, 2019 Share Posted May 24, 2019 So, this is actually impossible to do? JSR Kernel (draw the PF etc.) JSR DrawSprites (draw the player) Correct. You're generating the display in real time so you cannot update all of the playfield in one routine, then run another routine for the players as it's too late because the entire screen's already been drawn. 1 Quote Link to comment Share on other sites More sharing options...
JeremiahK Posted May 24, 2019 Share Posted May 24, 2019 Correct. You're generating the display in real time so you cannot update all of the playfield in one routine, then run another routine for the players as it's too late because the entire screen's already been drawn. Exactly. Everything must be drawn at the same time, playfield, players, missiles, and ball. Some games like Asteroids drew all the asteroids on one frame, and the player on the next, only drawing one or the other. This causes flickering, which is not fun to look at, and should be avoided at all costs. Quote Link to comment Share on other sites More sharing options...
IuriNery Posted May 24, 2019 Author Share Posted May 24, 2019 Thanks JeremiahK, I will take a look into your code to see if it works. I'm also going to take a look into the CollectMini on your tutorial SpiceWare, I think it has some stuff that I can learn from that, and it's less advanced then the actual tutorial itself, so it may be easier for me. Thanks! 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.