+ 1

Best way to draw to screen?

I'm working on a project with a pretty limited tool set, mostly have to build my own. The only included function for drawing to the screen is a drawPixel(x,y) type. I need to animate a 16×16 sprite by one pixel in any cardinal direction per frame. At first I thought to set each sprite as a 2d array and iterate over it to match some starting pixel, but that would be 256 iterations with about 35ish machine instructions. Then I thought to write a series of functions to poke the right memory addresses and update the word directly, and use an animate function to coordinate them. This would be 16-32 calls to poke() with 4 machine instructions each, so way more efficient, but I needed 16 functions to handle the sprite being split between 2 bytewords. Then another function to coordinate caning these. My problem is this method was animating smoother, but I also had new issues and it is so much harder to read than my first version that finding the bugs is a huge chore. Is there a better way?

19th Apr 2023, 3:12 AM
Bob
17 Respuestas
+ 2
Bob It's hard to suggest anything without knowing the programming language you plan to use and the hardware limitations. But maybe something like this? https://m.youtube.com/watch?v=PUcXXCPHlnE or perhaps it's a basic hardware project? https://projecthub.arduino.cc/debanshudas23/a6984de2-ac51-44b2-b0c3-064228d24c2d 16x16 does not have to be small https://m.youtube.com/watch?v=jkg7T7jlIzU edit-- I reread your post and it sounds like you're planning to code this in assembly language. And you want it very small, too. 😅... wow.
19th Apr 2023, 8:51 AM
Bob_Li
Bob_Li - avatar
+ 2
I don't want to say too much because I've been warned about mentioning courses outside of sololearn, but the course is called nand2tetris. The pl jack. The whole course is basically: design the "hack" computer in HDL, create an assembler, then a vm and compiler for the " jack" language. I've already done the vm portion(it's in my code bits, actually). After that, you're supposed to do a small game in Jack, then the compiler. I've done tiny games like this before, but always with high-level tools someone else built. This is the lowest level/ most sparce tool set I've ever used, and it's honestly been a little discouraging. I may have bitten off more than I was ready for.
19th Apr 2023, 8:11 PM
Bob
+ 2
Bob Bob_Li I believe the warnings you received are intended as suggestions that seeking programming-related help in the appropriate community can be more beneficial. By asking questions in the relevant community, programmers can obtain more targeted and accurate answers to their inquiries based on experience and resources. Try this forum if you hadn't already. http://nand2tetris-questions-and-answers-forum.52.s1.nabble.com/
19th Apr 2023, 11:29 PM
Chris Coder
Chris Coder - avatar
+ 1
It sounds like you're creating something for an 80's gaming console. What is the purpose of your project?
19th Apr 2023, 3:23 AM
Chris Coder
Chris Coder - avatar
+ 1
Actually kinda. I'm just kinda exploring the relationship between hardware and software, and 80s is about the most complex I can handle thinking about at this level right now. now that I think about it though, emulator communities are probably a good place to ask
19th Apr 2023, 3:32 AM
Bob
+ 1
It isn't and I'm almost embarrassed to put it there now because this is so much better than what I was trying to do. I may later though just to keep myself humble in years to come 😆
19th Apr 2023, 5:27 AM
Bob
+ 1
Yeah that's the course website. https://drive.google.com/open?id=1O0lZ3oXHhcMrKJJ_byCfz-6Wjgtf7n6q&authuser=schocken%40gmail.com&usp=drive_fs is the project description and has a link to the error codes and the language api if nothing else, it has really made me think of multiple ways to accomplish the same thing and choose the best
19th Apr 2023, 10:06 PM
Bob
+ 1
Chris Coder thanks, the other forum I'd found had been inactive for about 3 years
19th Apr 2023, 11:56 PM
Bob
0
Bob this one? https://www.nand2tetris.org/software#:~:text=Used%20to%20test%20and%20run,its%20binary%20and%20assembly%20versions. Purists might complain that it does not involve Sololearn courses, but it is still programming related and you could argue that it is advanced compiling exercise..😁 Computer emulation sounds fun.
19th Apr 2023, 9:54 PM
Bob_Li
Bob_Li - avatar
0
Bob Great links. Perhaps lurking low level programming gurus could chime in with better tools for those wanting to try their hand on this level of programming. Maybe there are ways to do this without having to go through a compiler everytime? The bitmap editor looks fun https://m.youtube.com/watch?v=a9NakmoimJI&feature=youtu.be You know what they say about Javascript? Everything that can be written will eventually be written... in Javascript. 🙃 https://github.com/ErikUmble/JackBitmapEditor/blob/main/JackBitmapEditor.html
19th Apr 2023, 10:16 PM
Bob_Li
Bob_Li - avatar
0
I've used that, it produces that series of functions per frame, play with it and you will see it works off of doing a poke to a specific memory address instead of anything in relation to x,y. That would have been fine if I wanted the sprite to move 16 pixels at a time. I'll just swallow my pride in a failed attempt and post the code when I get back home. That'll probably help get answers sooner
19th Apr 2023, 10:39 PM
Bob
0
Bob The html code for the JackBitmapEditor works in Sololearn if you copy the raw html code and paste it in Sololearn web codebit html tab. The style is terrible though. Big tables everywhere. I'm in the process of trying to clean that up so it's a bit mobile friendly. Don't hold your breath, though. I imagine you could tweak the js script to customize other parameters not included in the original code.
19th Apr 2023, 11:00 PM
Bob_Li
Bob_Li - avatar
0
Chris Coder ok. Thanks for the link.
19th Apr 2023, 11:33 PM
Bob_Li
Bob_Li - avatar
0
You're welcome Bob and Bob_Li I hope you find it useful.
20th Apr 2023, 5:58 PM
Chris Coder
Chris Coder - avatar