|
ForumsSega Master System / Mark III / Game GearSG-1000 / SC-3000 / SF-7000 / OMV |
Home - Forums - Games - Scans - Maps - Cheats - Credits Music - Videos - Development - Hacks - Translations - Homebrew |
Author | Message |
---|---|
|
DevKit SMS Scrolling Differential
Posted: Tue Mar 16, 2021 9:03 am
|
hello everyone i'm sorry for my english ... how do i scroll just the bottom part of the screen with the interruptions? because when I do my scrolling it always starts from the top to the line I asked for example: setlinecounter (120) ... I would like to interrupt everything before 120 ... from 0 to 120 stop and scroll from 120 to 192 ... thank you in advance I discovered your incredible site | |
|
Posted: Tue Mar 16, 2021 11:17 am |
if you want to change the horizontal scroll register mid-screen, you have to use a line interrupt.
so you might want to do something like this: void your_handler (void) { SMS_setBGScrollX (bottom_part_scroll); SMS_disableLineInterrupt(); } void main (void) { // your setup code here SMS_setLineInterruptHandler (your_handler); while (true) { // your game code here SMS_waitForVBlank (); SMS_setLineCounter (which_row_to_break); SMS_enableLineInterrupt(); SMS_setBGScrollX (top_part_scroll); } } so you see, you basically must wait for the vblank and enable the line interrupt, after having set the line where you want to split the screen (if this is constant it can be moved outside the loop of course, in the setup part) and reset the scroll for the top part of the screen. your handler will be called at the specified line and will change the scroll value to the one you want for the bottom part. edit: I recalled I had written this before - check the example here |
|
|
Posted: Tue Mar 16, 2021 1:03 pm |
thank you very much i will try tonight | |
|
Posted: Wed Mar 17, 2021 12:42 pm |
big thank you, it was successful for the differential scrolling again thank you. I plan to do a shoot em up on sega master system I am a beginner in C Language ... I managed to launch a missile from my ship, ... but several Missiles I can't do it for moment ... is there a technique to make a burst of fire by pressing once on the button or to keep constantly pressing the button ... thank you to you | |
|
Posted: Wed Mar 17, 2021 1:35 pm |
you probably want to set some variable to zero when you press the fire button and you release the first shot, then keep on incrementing that variable if the button is held down... and shoot again if the variable reaches some number of frames.
you need SMS_getKeysPressed() to see when a button that wasn't pressed becomes pressed and you need to use SMS_getKeysStatus() (or in alternative SMS_getKeysHeld()) to see if the button is held down, for example in #define FIRE_THRESHOLD 15 // shoot every 15 frames
if (SMS_getKeysPressed() & PORT_A_KEY_1) { fire(); shoot_again=0; } else if (SMS_getKeysStatus() & PORT_A_KEY_1) { if (++shoot_again==FIRE_THRESHOLD) { fire(); shoot_again=0; } } |
|
|
Posted: Fri Mar 19, 2021 5:57 pm |
thanks i am building all this ... for the fire () function i am wondering what to put in it, a variable in the addsprite function then i increment the variable, is it like that? | |
|
Posted: Mon Mar 22, 2021 10:30 am |
you probably want to handle more than one bullet at a time on screen but basically the point is you need to keep their positions in some variables in RAM, then you have to loop over them and update their positions according to the direction they're moving
of course then you call the addSprite function to draw them on screen according to their positions |
|
|
Posted: Tue Mar 23, 2021 5:11 pm |
thank you, I think I make tables to achieve the shots ... | |
|
Posted: Mon Apr 05, 2021 6:03 pm |
hello on my presentation page I would like to make a flashing "PRESS START BUTTON", it is not possible to do it in sprite because it exceeds 8 sprites per line .. I would like to find a method or to recover it on the bank tiles ... I looked in the SMSlIb.h but I can't find the function to use to recover the tiles and make them appear and then disappear, I don't know if this is the right method, thank you for your help. | |
|
Posted: Mon Apr 05, 2021 9:56 pm |
One possible way to do that is to create an image with the text written in it.
Any size would do but let's keep the dimensions at multiple of 8, so say you might want to make the image 160×8. You then convert the image with BMP2Tile to some tiles and a tilemap. You load the tiles in VRAM, the same way you do with other tiles, and to make that appear you update part of the pattern names table (the background tilemap on screen) using SMS_loadTileMap function. Alternatively, one even simpler method is to write the text in the background title image you are already showing and you change the palette so that to make the color of the text become the same color that you're using around it (say - black for instance) so the text will disappear of course it will reappear if you set it to back the original color |
|
|
Posted: Mon Apr 05, 2021 11:29 pm |
If you're okay with a half-transparent effect you can render every other letter per frame using sprites:
Frame N: P E S S A T
Frame N+1: R S T R Then for flashing the whole thing you just have your outer loop alternate between displaying neither set or displaying one of the sets and it'll be a flashing, half-transparent PRESS START. |
|
|
Posted: Tue Apr 06, 2021 7:56 am |
2 ways to make this easily :
• switch 2 tilemaps, one "empty" (background empty tile), one with tiles/text • switch color palette if your background is a pure color (like black), you can even make a little fade in/out effect with few colors instead of the classic black / white |
|
|
Posted: Tue Apr 06, 2021 3:49 pm |
Thank you friends, I will test it all again thank you | |
|
Posted: Tue Apr 06, 2021 4:15 pm |
• switch 2 tilemaps, takes up a lot of memory? if I understood correctly, 2 images must be swapped:
the image with (Press start) and the same image without (the Press start) cycle_counter = cycle_counter + 1; if (cycle_counter == 20) { // animation 1 SMS_loadTileMap (0, 0, (unsigned int *) ScreenPressStart_bin, ScreenPressStart_bin_size); } else if (cycle_counter == 40) { // animation 2 SMS_loadTileMap (0, 0, (unsigned int *) Screen_bin, Screen_bin_size); cycle_counter = 0; } |
|
|
Posted: Tue Apr 06, 2021 4:39 pm |
I wouldn't update the whole tilemap, just a part of it.
Say your image is 160×8 pixels, that's 20×1 tilemap. You can load that horizontally centered (at X=6) and at Y=21, for instance, by doing: SMS_loadTileMap (6, 21, (unsigned int *) ScreenPressStart_bin, ScreenPressStart_bin_size);
Then, when you want to remove that, you could do: SMS_VRAMmemsetW (XYtoADDR(6,21), EMPTY_TILE, 20*2);
so to write 20 empty tiles (20*2 = 40 bytes) over that image (of course EMPTY_TILE should be defined according to where you've got one in VRAM) edit: if your image is taller than one single tile, you should use SMS_loadTileMapArea instead, as SMS_loadTileMap can't handle tilemaps that are taller than 1 tile if they're not 32 tiles wide. |
|
|
Posted: Sat Apr 10, 2021 10:05 pm |
Thank you that worked :) | |
|
Posted: Fri May 07, 2021 10:25 pm |
hello i'm testing an effective crash test between missiles and enemy, can with the devkit we can make a structure like this?
he does not want to compile it I have the error: syntax error token -> 'box 1' //here is my code typedef int bool; #define true 1 #define false 0 struct AABB { int x; int y; int w; int h; }; bool Collision(AABB box1,AABB box2) { if((box2.x >= box1.x + box1.w) // too right || (box2.x + box2.w <= box1.x) // too left || (box2.y >= box1.y + box1.h) // too down || (box2.y + box2.h <= box1.y)) // too up return false; else return true; } // I'm sorry I'm starting...if you have examples i'm interested ,thanks |
|
|
Posted: Fri May 07, 2021 10:51 pm |
The error is in this line: bool Collision(AABB box1,AABB box2)
The type is struct AABB instead of just AABB. If you want to use AABB instead, you need to use typedef to define a type AABB as the struct. |
|
|
Posted: Fri May 07, 2021 11:17 pm |
example of my project
|
|
|
Posted: Sat May 08, 2021 4:52 am |
Looks very nice. The player ship reminds me of Axelay. You might want to rethink your status bar. Making score digits and shield symbols 8x8 pixels in size will make your life much easier, trust me. |
|
|
Posted: Sat May 08, 2021 9:31 pm |
Thanks, if you have a small example of code, I would understand a little better, thank you | |
|
Posted: Sat May 08, 2021 9:39 pm |
the ship looks like Axelay's but we are on the master system ... :)
for the HUD I count improved in 8x8 and the enemies it is just for my tests ... I first try to succeed in a functional engine ... the graphic part is what I like |
|