Оберон-клуб «ВЄДАsoft» https://zx.oberon.org/forum/ |
|
Drawing some bytes to the screen https://zx.oberon.org/forum/viewtopic.php?f=10&t=123 |
Страница 1 из 2 |
Автор: | slenkar [ 24 июн 2013, 20:52 ] | ||
Заголовок сообщения: | Drawing some bytes to the screen | ||
I put a new function in basic drawchar Цитата: void Basic_drawchar(SHORTINT gfx,SHORTINT x,SHORTINT y) { __asm #ifdef __SDCC PUSH IX LD IX,#0 ADD IX,SP #endif LD D,4(IX) LD B,5(IX) LD C,6(IX) LD HL,#16384 LD A,B ADD A,L LD L,A LD A,C CP #8 JP NC,secondthird$ RRC A RRC A RRC A OR L LD L,A JP drawing$ secondthird$: CP #16 JP NC,thirdthird$ LD A,#8 ADD A,H LD H,A LD A,C SUB #8 RRC A RRC A RRC A OR L LD L,A JP drawing$ thirdthird$: LD A,#16 ADD A,H LD H,A LD A,C SUB #16 RRC A RRC A RRC A OR L LD L,A drawing$: LD A,D CP #1 JP NZ,dontdraw$ LD A,#255 LD (HL),A INC H LD (HL),#129 INC H LD (HL),#129 INC H LD (HL),#129 INC H LD (HL),#129 INC H LD (HL),#129 INC H LD (HL),#129 INC H LD (HL),#255 dontdraw$: LD A,4(IX) CP #2 JP NZ,dontdraw2$ dontdraw2$: #ifdef __SDCC POP IX #endif __endasm; } check out the attachment to see it in action Im putting the bytes of the graphic inside the drawing function but I want to make function accept a pointer to some graphics, how would I do that? Could I put some numbers(bytes) into an oberon array and pass the pointer to the array to asm? Also it seems that SHORTINT is signed -127 to 128 I need an unsigned byte but SHORTCARD isn't accepted by ofront
|
Автор: | slenkar [ 25 июн 2013, 04:28 ] |
Заголовок сообщения: | Re: Drawing some bytes to the screen |
ok I looked at printstring to figure out how to do it Цитата: void Basic_drawchar_func(SHORTINT *gfx, SHORTINT x,SHORTINT y) { __asm #ifdef __SDCC PUSH IX LD IX,#0 ADD IX,SP #endif LD E,4(IX) LD D,5(IX) LD B,6(IX) LD C,7(IX) LD HL,#16384 LD A,B ADD A,L LD L,A LD A,C CP #8 JP NC,secondthird$ JP drawing$ secondthird$: CP #16 JP NC,thirdthird$ LD A,#8 ADD A,H LD H,A LD A,C SUB #8 JP drawing$ thirdthird$: LD A,#16 ADD A,H LD H,A LD A,C SUB #16 drawing$: RRC A RRC A RRC A OR L LD L,A LD (HL),#255 INC H INC DE LD A,(DE) ADD #128 LD (HL),A INC H INC DE LD A,(DE) ADD #128 LD (HL),A INC H INC DE LD A,(DE) ADD #128 LD (HL),A INC H INC DE LD A,(DE) ADD #128 LD (HL),A INC H INC DE LD A,(DE) ADD #128 LD (HL),A INC H INC DE LD A,(DE) ADD #128 LD (HL),A INC H INC DE LD A,(DE) ADD #128 LD (HL),A #ifdef __SDCC POP IX #endif __endasm; } I have to find out how to turn a signed byte into unsigned now EDIT- ohh put ADD #128 to every byte |
Автор: | Zorko [ 25 июн 2013, 11:58 ] |
Заголовок сообщения: | Re: Drawing some bytes to the screen |
Yeah, very good! slenkar писал(а): Could I put some numbers(bytes) into an oberon array and pass the pointer to the array to asm? General question: how to specify a data (sprites, fonts, tiles, levels, music etc) in an Oberon program? That is a problem, therefore Oberon has not constant arrays (like Turbo Pascal or C). Maybe we'll fix this problem in future.Then now you can specify data in a non-constant array: Код: "OBERON"
The same way I've used in the game Dash. See: Oberon interface: https://github.com/Oleg-N-Cher/Dash/blob/master/Src/ZxSpec%20(Ofront-SDCC)/Mod/Rsrc.odc C implementation: https://github.com/Oleg-N-Cher/Dash/blob/master/Src/ZxSpec%20(Ofront-SDCC)/Rsrc.c I recommend you do not call the procedure "drawchar". Why? Because your drawchar will be draw not only chars, and rather, the tiles - small squares that make up a graphic. For ZX it's good to have size 8x8 pixels (or 16x16). With color, or without. I propose to start a new library GrTiles. At first, it may contain such interface: Код: "OBERON"
slenkar писал(а): Also it seems that SHORTINT is signed -127 to 128 To add this feature, you need to rebuild Ofront for Linux with this changes (see the commit) and use SYSTEM.SHORTCARD, SYSTEM.CARDINAL, SYSTEM.LONGCARD. But it's a very basic support of unsigned types (may be problems), we must improve it.
I need an unsigned byte but SHORTCARD isn't accepted by ofront |
Автор: | Zorko [ 25 июн 2013, 12:09 ] | ||
Заголовок сообщения: | Re: Drawing some bytes to the screen | ||
I want to suggest another way to define a data in Oberon program. See this code: And another question: can a Basic loader be written in Oberon? Yes, it's even relocatable! And may be placed in a Basic line after REM: Код: "OBERON"
P.S. Procedures DEFDATAREL, DATA*, READ was added today, re-download the Basic library.
|
Автор: | slenkar [ 25 июн 2013, 18:57 ] |
Заголовок сообщения: | Re: Drawing some bytes to the screen |
there are a couple of things I dont understand about that example where does 96-12-6 come from? Does basic loader mean loading screen? Can I use decimal instead of hex? |
Автор: | Zorko [ 25 июн 2013, 21:49 ] |
Заголовок сообщения: | Re: Drawing some bytes to the screen |
slenkar писал(а): where does 96-12-6 come from? It's data size, specified after DEFDATAREL. Constant (calculable) expression that is:768 bytes (ZX's screen attributes) DIV 8 = 96 bytes (all of attribute bytes are packed into bits) - 12 (upper blank attribute lines on screen) - 6 (lower blank attribute lines on screen) slenkar писал(а): Does basic loader mean loading screen? It's just a part of the loader's functions. It has packed attribute screen, and unpack/show it. Except this, it will be load a code block from tape/TR-DOS disk (the last feature isn't implemented yet).slenkar писал(а): Can I use decimal instead of hex? Sure. Use a decimal value every time where hex may be written. And if you need to specify a character by a decimal code, use CHR(DecCharCode).P.S. If you want to know more about how to work with bits in Oberon, there is article "Wirth N. SET: A neglected data type, and its compilation for the ARM". |
Автор: | slenkar [ 26 июн 2013, 02:29 ] |
Заголовок сообщения: | Re: Drawing some bytes to the screen |
I read about SET in 3 different Oberon manuals and I still dont understand them ![]() ![]() why is MAX(SET) on spectrum 31? That would mean it uses 6 bits? If I knew why 31 it would help me understand |
Автор: | Zorko [ 26 июн 2013, 12:41 ] |
Заголовок сообщения: | Re: Drawing some bytes to the screen |
slenkar писал(а): I read about SET in 3 different Oberon manuals and I still dont understand them In fact, Oberon's SET is machine-independent and maximally right way to work with bits. ![]() ![]() ![]() ![]() slenkar писал(а): why is MAX(SET) on spectrum 31? Why 31? I've launched:Код: "OBERON"
7 6 5 4 3 2 1 0 If you want to use all bits set, just write: Код: "OBERON"
Код: "OBERON"
Код: "OBERON"
Btw, I've used MAX(SET) = 7 only for ZX. So it is made for more efficiency. In Oberon (and in WinDev) it is really 31 - that corresponds to 0 to 31 bits = 4 bytes. And you can set this value for your own project in the Ofront configurator - the file Obj/Ofront.par: type size(bytes) alignment SET 1 1 As Oberon is a strongly typed language, it does not encourage work with bits as numbers and with numbers as bits. I think it's very good decision, because it encourages more accurate to formalize problems, but it does not encourage a quick and dirty coding. Therefore many C programmers do not like Oberon (and Modula-2 too). ![]() |
Автор: | slenkar [ 27 июн 2013, 23:28 ] |
Заголовок сообщения: | Re: Drawing some bytes to the screen |
thanks I think I get it now let me know if this sounds good Код: "OBERON"
we need gettile to make sure other sprites that are not moving dont get deleted from the screen For DOS: If you look at turbo C it has a BGIDEMO, I think we only need putpixel and getpixel |
Автор: | Zorko [ 28 июн 2013, 15:36 ] | |||
Заголовок сообщения: | Re: Drawing some bytes to the screen | |||
I've planned to place tile graphic and pixel graphic to different modules, it's a way to have unified look to graphic at all, and possible independent from a platform. You can to start implementation of that interface proposed by you, and look what I've done today. ![]() Код: "OBERON"
I have tried to unify the view of the tiles as a whole, and try to design platform-independent tiles that will be a good as for Spectrum, as for other platforms (DOS, Windows, Linux (SDL)). DrawTile8x8 needs to be able to specify tile size, and to have (in future) a possibility to draw tiles with different size (DrawTile16x16, DrawTile8x16, DrawTile16x8, etc). DrawTile needs to be able to work with tiles without specifying their size (it's good for crossplatform development). For example, you will have under ZX the tile size 8x8 (two-colors), and under MS-DOS - 10x10 (colored). But a game's main logic module may be the same. SetColors and DrawMonoTile need to be able to draw monochrome (or rather even two-colors) tiles, with a possibility to specify this colors (attributes). This is a traditional look for old good classical graphics libraries - background and foreground (or paper and ink). This mono tiles may be conveniently used for drawing characters, frames, pseudo graphic, etc. Because in old school for such things are often of use of little colors, and I like this approach even for modern platforms. In addition, we can then add a drawing with logical operations (and, or, xor), transparency, etc. So you can see what I made today in this direction. Код: "OBERON"
|
Страница 1 из 2 | Часовой пояс: UTC + 2 часа |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |