Posted By
George on 2012-08-13 05:03:18
| Combining Text and freely placeable bitmaps on screen
First I apologize for my annoying beginners questions here, but i need some general background information about dealing with graphics on the plus/4.
My goal: I want to make an interactive text based story with small, (not full screen) pictures in it. The pictures and texts should be freely placeable on the screen and not to much colors are needed. My first try, is to make it in Graphicsmode 3 (HIRES-COLOR Mode), make the pictues with a tool (csabos gfx Edit), save as prg and load them. The code will be in Basic.
1) Are there better techniques than this? If yes, please give me an overview for a beginner like me. Explain please the pros and cons. And how to to it in basic. 2) When i load the picture (50x80) as prg in my basic-programm (from csabos editor as hires-bitmap), the colors are diffrent and the picture is top left. How do i change the colors in the programm and how do i move the picture to another position?
Thanks in previous for an answer.
|
|
Posted By
Csabo on 2012-08-08 09:44:26
| Re: Combing Text and freely placeable bitmaps on screen
Some of this is a bit unclear to me. Graphic 3 = hires? 1 should be hires, 3 should be multi. Which one do you mean exactly?
As for "freely placeable"... Sounds like you want to create some 6 chars by 10 chars bitmaps, and load and position them on the graphics screen? If so, there's no easy way to do it from BASIC. From ML, it's pretty trivial though.
If you use my editor to create non full-screen bitmaps (which, as a game programmer, I find is often necessary, yet none of the other tools seem to do this), it will be in a format that is not ready to be placed onto the graphics screen. You'll need something (either a bunch of PEEK/POKEs, or a short ML routine) to copy it to the screen for you.
|
|
Posted By
George on 2012-08-08 10:00:48
| Re: Combing Text and freely placeable bitmaps on screen
Graphicmode 3 is ment here. (i called it Hires (falsewise), because you can set a single Pixel). My Goal: I want to set singel Pixels with color and write with my charset.
Csabo: Your tool can import bmp's in any size, which i corrected them. But, I dint find out, how you change the 4 colors? Shift+1 didnt work. The Help-file do not work on Window 7 either.
Lets say, i defined my Bitmap (50x100 Pixels), save it as Prg. I want to position it freely on screen. How is this done in ML? If you you have a procedure for this it would be perfect. And why are the colors not the same as in your Tool?
|
|
Posted By
Csabo on 2012-08-08 12:10:38
| Re: Combing Text and freely placeable bitmaps on screen
"But, I dint find out, how you change the 4 colors? Shift+1 didnt work." In GfxEdit, go to View / Image Properties (or just press P). Make sure that under "Color Map" you have "Normal" selected. If it's "None", then you're editing the bitmap only, this is useful for sprites, etc.
"Lets say, i defined my Bitmap (50x100 Pixels), save it as Prg." Did you use the export as PRG function? Then you're exporting the full 320x200 bitmap. This is probably NOT what you want to do, it will store a lot more information than necessary. If you want to work with a smaller bitmap, "Save as source" is your only option. You can easily put that into an ASM file and compile it. Depending on how many images you have, you may be able to put ALL of them into a single file and keep it in memory. This would eliminate the need for loading.
"I want to position it freely on screen. How is this done in ML?" As long as you're copying them to character boundaries, it's just two loops of copying bytes (assuming you have the source and destination addresses). However, if you want to be able to copy them to any pixel position, it's much, much more complicated, you'll need to shift your data both horizontally and vertically. The 50 x 100 pixels size is odd, 50 is actually 6 chars + 2 more pixels, and 100 is 12 chars + 4 more pixels.
"And why are the colors not the same as in your Tool?" I don't know, no idea what you did. Maybe you can post some screens (or PM me the links)?
|
|
Posted By
George on 2012-08-08 12:28:56
| Re: Combing Text and freely placeable bitmaps on screen
Thanks Csabo,
Now i understand, why you referred to the Bitmap-dimension in characters (2x6) and not in Pixels. It has to do how the screen is mapped in Memory (Bytewise).
I will make the bitmaps in Char-boundaries for first. The two loops i guess are one for the pixel-Map and one for the Luminace Map.
I will try and give feedback.
|
|
Posted By
gerliczer on 2012-08-08 12:46:38
| Re: Combing Text and freely placeable bitmaps on screen
Hi George,
I took a short try with Csabo's excellent programmers' graphics editor Csabo's Gfx Edit to see what causes your problem. If you save your picture as a program file, it will contain a full graphic screen, which is a waste of space in your case. The difference in colours comes from the fact that the colour memory loaded with the file is not at the place where it is used in COMMODORE BASIC. You should copy the contents of memory between $1800 and $1F40 to $0800..$0F40 to get your intended colours. Not too many years ago there was a thread in the forum about the possibilities of fast memory copying in BASIC. Look it up and use what we came up with back then.
Now about the possibilities of more efficient storage. As Csabo already said, you should try to save the pictures as source code. Draw or convert your picture, save as source, copy the text into Plus4IDE, write before the text in the first line ORG $1800-2 and DW $1800 in the next (the previously inserted text must start in the third line now - but this is obvious), save it, and finally build the "program". Now you have a file that contains only the graphic and colour data that you need. When loading the file it will be residing in the memory from $1800. You should be careful not to make too large pictures, because the graphic screen already starts at $2000. The file will contain first the graphic data, next the luminance data, and finally the colour data. Observe, that the breakdown of the data gives you hint where the contiguous graphic data blocks start and end.
Then comes the hardest part, putting the picture into its place. This is the part where we welcome you to the wonderfully fucked up world of the Commodore graphic screen. Let's start with the memory organization of the actual graphic screen. The sequential bytes of the graphic screen memory are mapped to the actual displayed screen not in a horizontal sequence of one screen line followed by the next one. They are following the display order of the character data, therefore the first byte is displayed at the top left corner. It represents the first 4 or 8 pixels counting from left of the top screen line. The next byte is displayed below the previous, therefore it represents the first 4 or 8 pixels (0..3 or 0..7) counting from left of the second screen line, the one below the top. This goes 8 times, so the 8th byte is the left 4 or 8 pixel of the 8th screen line. The 9th byte then is right beside the 1st one of the screen memory. It represents the second 4 or 8 pixels (4..7 or 8..15) of the first line, and this goes on 40 times. The 321st byte will represent the leftmost 4 or 8 pixels of the 9th line. And this carries on along the whole screen. Then come the colour and luminance matrices. The luminance starts at $0800 and the colour at $0C00, but maybe I mixed them up. These are following the usual linear layout of the character screen and are equal with those in size, therefore you colours will be the same in every 8*8 or 4*8 pixel area.
Now all you have to do is calculating the addresses of the screen memory where the contiguous blocks of graphic data must be copied, and what are the corresponding addresses in the colour and luminance matrices. I know that all this is very frightening at first, but give it a try.
|
|
Posted By
George on 2012-08-08 13:04:28
| Re: Combing Text and freely placeable bitmaps on screen
Thanks gerliczer for your usefull information.
I read some books the Plus/4, but as programmer myself, i always ask the experienced guys first, before spending hours on the first-time mistakes, everybody makes.
I knew about the pixel-organisation, and its really fucked up. Never understood this 8x8 logic.
I will try and give feedback, hopefully with good results and screenshots. Perhaps i will need some help for the ML copy-routine. I don't work with ML every day.
|
|
Posted By
gerliczer on 2012-08-08 14:26:31
| Re: Combing Text and freely placeable bitmaps on screen
Hi George,
If you want pixel precision then you definitely need ML, but if you settle for character boundary precision then look up the topic "Defining a custom charset from BASIC" in the forum. The solution there is simple BASIC with one single ROM call which can be used in this case too. Easy stuff.
|
|
Posted By
George on 2012-08-08 18:33:12
| Re: Combing Text and freely placeable bitmaps on screen
Plus 4 IDE seems not to work on Win7. Problem known? I made it on a XP system.
I give it up for today. The loading works, m 1800 has the right results. Copying per hand to 2000 works. i do see the chars ligned up.
I tried something simple in basic, but the code hangs while loading "grag": Idea is to poke the first character.
10 graphic 4,1 20 load"grag",8,1 25 REM copy first 8 bytes from 1800 to 2000 30 for i = 0 to 7 40 poke 8192+i, (PEEK(6144+i)) 50 next
Well i do not understand where the bit/color/luminance blocks are beginng or ending.
grag export data (7x11 chars): ; 56*88 m DB $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF DB $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF DB $FF,$FF,$FF,$FC,$F3,$CF,$CF,$3F DB $FF,$FF,$FF,$03,$F3,$FC,$FF,$FF DB $FF,$0F,$33,$3C,$0C,$FF,$FF,$3F DB $FF,$FF,$FF,$FF,$FF,$3F,$3F,$3F DB $FC,$FC,$FC,$FC,$FC,$FC,$FC,$FF
DB $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF DB $FF,$FF,$FC,$FC,$C3,$3F,$3F,$3F DB $3F,$03,$FC,$FC,$FF,$FF,$FF,$FF DB $FF,$FF,$FF,$FF,$3F,$CF,$C3,$F3 DB $3F,$03,$FC,$FF,$FF,$F0,$FF,$CF DB $FF,$FF,$FF,$3F,$3F,$3F,$CF,$F3 DB $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
DB $FC,$FC,$F3,$F3,$F3,$CF,$CF,$3F DB $FF,$FF,$FF,$FF,$FF,$FC,$FC,$FC DB $FF,$FF,$FC,$FC,$FC,$FC,$FC,$F3 DB $F3,$FF,$FF,$FF,$FC,$F3,$F3,$FC DB $CF,$CF,$F3,$F0,$FF,$3F,$00,$33 DB $3C,$3C,$3F,$3F,$3F,$FF,$FF,$FF DB $FF,$FF,$3F,$3F,$FF,$CF,$CF,$F3
DB $FF,$FF,$FF,$FC,$FC,$C3,$CF,$CF DB $FC,$FC,$FF,$FF,$FF,$FF,$FF,$FF DB $0F,$FF,$00,$F1,$F1,$F1,$C5,$C5 DB $CC,$0C,$03,$30,$01,$55,$55,$55 DB $33,$33,$C3,$03,$53,$57,$54,$57 DB $FF,$FF,$FF,$FF,$FF,$FF,$0F,$0F DB $F3,$FC,$FC,$FC,$FC,$FC,$FC,$FC
DB $3F,$FF,$FF,$FF,$FF,$FF,$FF,$FF DB $FF,$FF,$FF,$FF,$FC,$FC,$FC,$FF DB $C5,$15,$15,$15,$15,$15,$11,$14 DB $55,$55,$55,$55,$55,$55,$55,$55 DB $54,$54,$54,$55,$55,$55,$55,$01 DB $33,$33,$0F,$0F,$3F,$3F,$3F,$3F DB $FC,$FC,$FC,$FC,$FC,$FC,$FC,$F3
DB $F3,$F3,$F3,$CF,$CF,$CF,$CF,$CF DB $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF DB $C4,$C5,$F0,$FC,$FF,$FF,$FF,$FF DB $00,$55,$55,$00,$FF,$FF,$FF,$FF DB $14,$53,$4F,$3F,$FF,$FF,$FF,$FF DB $FF,$FF,$FF,$FF,$FF,$FC,$FC,$FC DB $F3,$CF,$CF,$CF,$3F,$FF,$FF,$FF
DB $F3,$F3,$F3,$F3,$C3,$F3,$FC,$FC DB $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF DB $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF DB $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF DB $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF DB $F0,$F0,$F0,$F3,$F3,$F0,$F3,$F3 DB $FF,$CF,$0F,$3F,$3F,$3F,$FF,$FF
DB $FF,$FF,$FF,$FF,$FF,$FF,$C3,$33 DB $FF,$3F,$CF,$C3,$F0,$FF,$FF,$FF DB $FF,$FF,$FF,$FF,$FF,$0F,$00,$3F DB $FF,$FF,$FF,$FF,$FF,$FF,$0F,$F3 DB $FF,$FF,$FF,$FF,$FF,$FF,$FC,$FC DB $CF,$CF,$CF,$CF,$3F,$3F,$FF,$FF DB $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
DB $FC,$FF,$FF,$FF,$FF,$FF,$FF,$FF DB $FF,$3F,$3C,$CC,$C3,$CF,$CF,$CF DB $3F,$3F,$C3,$F3,$F3,$FC,$FF,$FF DB $F3,$F3,$F3,$CF,$CF,$00,$FC,$FC DB $CC,$CF,$33,$3C,$3C,$FC,$FC,$FC DB $CF,$0F,$CF,$3F,$FF,$FF,$FF,$FF DB $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
DB $FF,$FF,$FF,$FF,$FF,$FC,$F3,$F3 DB $3F,$3F,$3F,$3C,$33,$33,$C3,$CF DB $FF,$FF,$00,$FF,$FF,$FF,$FF,$FF DB $FC,$FC,$FC,$3C,$3C,$CC,$F0,$F3 DB $FC,$F3,$F3,$F0,$F3,$F3,$C0,$0F DB $FF,$3F,$CF,$CF,$CF,$CF,$3F,$FF DB $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
DB $F3,$C3,$0F,$FF,$FF,$FF,$FF,$FF DB $F3,$FC,$FF,$FF,$FF,$FF,$FF,$FF DB $FC,$00,$F3,$F3,$F0,$FF,$FF,$FF DB $0F,$CF,$CF,$CF,$0F,$FF,$FF,$FF DB $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF DB $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF DB $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
DB $53,$53,$53,$53,$53,$53,$53,$53 DB $53,$53,$53,$53,$53,$53,$53,$53 DB $53,$53,$53,$53,$53,$53,$53,$56 DB $56,$56,$53,$53,$53,$53,$56,$56 DB $56,$56,$53,$53,$53,$56,$56,$56 DB $53,$53,$53,$53,$53,$54,$53,$53 DB $53,$54,$53,$53,$53,$53,$53,$5A DB $53,$53,$53,$53,$53,$53,$53,$53 DB $53,$53,$53,$53,$53,$53,$53,$53 DB $53,$53,$53,$53,$53 DB $11,$11,$11,$11,$11,$11,$11,$11 DB $11,$11,$11,$11,$11,$11,$11,$11 DB $11,$11,$11,$11,$11,$11,$11,$21 DB $21,$21,$11,$11,$11,$11,$21,$21 DB $21,$21,$11,$11,$11,$21,$21,$21 DB $11,$11,$11,$11,$11,$21,$11,$11 DB $11,$21,$11,$11,$11,$11,$11,$E1 DB $11,$11,$11,$11,$11,$11,$11,$11 DB $11,$11,$11,$11,$11,$11,$11,$11 DB $11,$11,$11,$11,$11
|
|
Posted By
Csabo on 2012-08-08 19:33:56
| Re: Combing Text and freely placeable bitmaps on screen
With Plus4IDE, there's two separate issues.
First, there is a little bug in it. It happens if you close Plus4IDE while minimized. (Minimize it, then right-click the window on the taskbar and choose close.) When you next open it, it restores itself off screen. You can right-click the taskbar and click Maximize, that will make it visible. But to properly fix it, choose Move, press cursor down, then move your mouse. This will bring it back. I should fix this...
The other issue is that AS65 only likes lowercase code on Win7. I already added an option for this, you can toggle it in the editor. I should make a release of this as well
Now, for your BASIC example: the problem is that when LOAD executes, the program restarts. So basically it will be stuck in an infinite loop, it keeps executing line 10 then 20, then 10 again, etc. To solve it, you can set a variable, something like this:
10 IF A = 1 THEN 30 20 A = 1 : LOAD "TEST", 8, 1 30 REM CONTINUE HERE
|
|
Posted By
gerliczer on 2012-08-09 01:42:52
| Graphics, luminance and colour
George,
Let's examine carefully the example you copied here. As I said earlier, first come the graphic data. You state it is 7 characters wide and 11 characters high. The first comment line shows 56*88 which is 8 times the width and 8 times the height you specified. Let's continue with the first block which consists of 7 lines of 8 bytes. One character area is 8 bytes and you have 56 of them which corresponds fairly well to one character line of 7 characters wide graphic data. If you continue your examination, you find that there are 11 such blocks which again corresponds quite well to the height of your picture. Now let's continue with the remaining blocks. There is two of them, containing 77 bytes each. This also corresponds to your 7*11 characters picture. If you start up Csabo's Gfx Edit you see the default colour settings being black and three shades of white, the 4th from the top, the 6th and the 8th. The colour code of white is 1 and the shade codes are 3, 5 and 7. Looking at your posted example we can see that you didn't change the local colours in too many places. Most of the first block contains $53 which corresponds to the luminances of default colour 1 and two, and similarly the second block looks to be the colour data with those $11s. I hope this will clear the picture, pun intended.
Csabo,
This save as source in the editor seems to miss exporting the two global colours while the save as program does it. (MULT[BYTE][BYTE] between the luminance and colour matrices vs. nothing)
P.S. It is a bit strange that George forgot the load-restart workaround trick that he was using in an example in the "Searchin' for a char editor..." topic.
|
|
Posted By
George on 2012-08-09 06:41:28
| Re: Combing Text and freely placeable bitmaps on screen
It was late after midnight yesterday after a hard working day. The Autoload-Issue didnt came in mind. Its not very intuitive for me, that graphic and load commands have this side effects.
@Csabo, gerliczer: In Win 7 the min/max was missing, in the Taskbar item.
GfX Edit: Really great tool, but changing the colors for 1-4 is not really intuitive for me. Please give me a short instruction. Sometimes it works, sometimes not. If you have an ear for ideas from a fellow Delphi-Developer: I would make additional 4 separate Color Fields (1-4) next to the palette. If you click on Field 1, Color 1 (I would make a bold border arount) is selected and you draw with this color (with left-Mouseclick). If you Right-click on the palette the selected color 1 is changed. Please don't be offended, only a suggestion. Another great thing for Beginners like me would to be export the Bitmap in that way, that the prg loads it to the position on Screen you want it. I am just giving ideas here.
@gerliczer: Re-Importung the file, misses the color i set (pink). I understand the file now. Thank you. How are the bytes encoded in the last two blocks?
I want to thank you all again for your help.
|
|
Posted By
gerliczer on 2012-08-09 09:33:27
| Re: Combing Text and freely placeable bitmaps on screen
Hi George,
Regarding Csabo's Gfx Edit I can say that picking colours seems to be very straightforward to me. Click in the palette to select the colour you wish to use, then select with pressing Alt+0, 1, 2 or 3 to tell the program how you want to use it. 0 and 3 are the two global colours that are used throughout the whole picture. Obviously 1 and 2 are the local colours which are valid in the individual character sized areas. What may be unintuitive is that after picking a local colour it will overwrite the previously used one if you would cause a clash.
Regarding the luminance and colour data exported by the editor I don't know exactly the encoding. But it isn't too hard to figure it out with a little experimenting. Pick two colours with different code and luminance as local ones (1 and 2), and draw some pixels in the top left character area with both of them. Now save it as source, and compare the low and high nibble of the first luminance byte with those you picked for the trial. Also compare the first colour byte similarly. This will show you the encoding.
|
|
Posted By
George on 2012-08-09 11:49:32
| Re: Combing Text and freely placeable bitmaps on screen
I am close to my goal:
10 IF A = 1 THEN 30 20 A = 1 : graphic 4,1: LOAD "grag", 8, 1 25 k = 0 30 for i = 0 to 55 35 p = 6144+(k*56)+i 40 poke ((8*4)+8192+(k*320)+i), (PEEK (p)) 50 next i 60 if k=10 then end 70 k=k +1: goto 30
Result: http://ww.patsos.de/plus4/Grag.JPG
When posting the color und luminance bytes i don't see any effect.
Update: I looked up the SVS ROM MAP:
"Using GRAPHIC command to manage Graphic modes: This command always sets as HiRes address: $2000; and as Luminace-table address: $1800; Colors-table address: $1C00"
I already use $1800 for caching the bitmap (scratch my head). Which adress could i use alternatively without sideeffects?
|
|
Posted By
gerliczer on 2012-08-09 12:11:22
| Encoding of luminance and colour data, and cache memory
Bits 0..2 of the luminance byte belong to colour 2 in Csabo's Gfx Edit, bits 4..6 belong to colour 1. Bits 0..3 of the colour byte belong to colour 1, bits 4..7 belong to colour 2 in the editor.
If BASIC remaps the colour matrices at $1800 (which must have caused that you couldn't see the effect of colours) then you may use the area used for the character screen. But you must be careful if you are using the split screen mode, because if the picture is too large (longer than 20*40 bytes) it may become visible in the bottom of the screen as garbage characters or wrong colours depending on whether you cache the pictures from $0800 or $0C00.
Some ideas to your program: - delete line 25 - replace line 30 with this: 30 for k = 0 to 10: for i = 0 to 55 - replace line 50 with this: next i,k - delete line 60 and 70
|
|
Posted By
George on 2012-08-09 17:49:13
| Re: Combing Text and freely placeable bitmaps on screen
Ah, thats the way to make a nested for-loop. Tried it with next i : next k
Here the first Result: http://www.patsos.de/plus4/Grag3.JPG
I had problems with caching in $0800 or $0C000. Wierd things on screen. So I choosed $6000. The Sprite is 770 Bytes long. I added Luminance and Color, but the colors except the pink nose are not right: Background schould be white and the lines should be black. Nose is Pink and thats ok.
My Result-Code: 10 IF A = 1 THEN 30 20 A = 1 : graphic 4,1: color 0,1: color 3,2: color 4,1: LOAD "grag",8,1 30 r=8:d=4 : REM Position 8x right, 4x down 40 s = 24576: x=8*r: y=(8*40)*d: REM Statadress + Shift to right 50 for k = 0 to 10:for i = 0 to 55 60 p = s +(k*56)+i 70 poke (x+y+8192+(k*320)+i), (PEEK (p)) 80 next i,k 90 100 rem Luminance $1800 110 for k = 0 to 10: for i = 0 to 6 120 p = p + 1 130 poke (r+(d*40)+DEC("1800")+i+(k*40)), peek(p) 140 next i,k 150 160 REMColor $1C00 170 for k = 0 to 10: for i = 0 to 6 180 p = p + 1 190 poke (r+(d*40)+DEC("1C00")+i+(k*40)), peek(p) 200 next i,k
The Code is of course very lame. But i am very happy about the result.
UPDATE: If you set this, color 0,1: color 3,2 the colors are right. See here http://www.patsos.de/plus4/Grag4.JPG
@Gerliczer: Any suggestions how to speed up the function? Even with Basic-Optimazation, it will be to slow. I found your quick Rom routine, but i did not understand, how to fill the parameters right.
|
|
Posted By
gerliczer on 2012-08-10 05:17:29
| Ideas to your latest BASIC example
Hi George,
First about the nested for loops. Your version should also work OK. Even if you write it as NEXT:NEXT, it should work.
Next about caching at $0800 or 0C00. Could you post the code and maybe a picture to see what went wrong? I think 770 bytes should not cause artefacts.
Then about the copy routine in the other topic. You should examine first its initial version which has some comments. Study the used system variables with the help of the RAM page in SVS's Ultimate Map. If you start to get it, then apply the version optimized by Csabo in your program.
Finally about speeding up the code. I cannot help you with this too much beyond the usual generic advices. - Fill BASIC lines as much as possible to decrease overhead. - Try to minimize the number of complex formula evaluations. - Do not use DEC("XXXX"), calculate the value manually and use it that way, because it takes unnecessary time, especially in a loop. - In line 60 you are calculating p in an unnecessarily complex way. It is linear as you use it in the colour restoring part, so initialize with the first address (which is 's') and then increment it by one. - If I see it right, the terms r+(d*40)+DEC("XXXX") are constant in the luminance and colour copying loops, evaluate them once before the loops. - Try to combine the two copying into one loop to decrease overhead. - Variable k should run from 0 to 400 with step of 40.
I hope this will help you a bit.
|
|
Posted By
George on 2012-08-10 03:55:05
| Re: Combing Text and freely placeable bitmaps on screen
Good Morning geliczer,
Nested Loop: My original nested loop works today (next i, next k in two lines). I suppose i made a mistake in the Line-Numbering (Code Blindness).
Caching to 0800 or 0C00: I suppose you a are right. Let me explain what i did. 1) I compiled the Export-Datas in Plus4IDE -> Grag.prg is loaded in Yape (Wierd chars at top) 2) MONITOR->M 0800 is ok! ->SAVE"GRAG",8,0800, xxxx (xxxx=0800+770bytes) to have it on a Disk for the LOAD in Basic 3) When i load the File in MONITOR again, again wierd chars at top, M0800 is not ok.
Perhaps i am doing something wrong here.
|
|
Posted By
gerliczer on 2012-08-10 04:41:36
| Graphic data file issue
Hi George,
I don't understand what you are trying to do with loading and saving again the data. If I understand it right, when you load the data first, it is correctly loaded at $0800. Why do you try to save it again? Although, if you are blindly following my previous example and make the data compile to address $1800 then you should replace the two assembly lines with ORG $0800-2 and DW $0800. After that you'll need no other steps like transferring to $0800 and saving again because it will load to the correct address.
You have to understand that the BASIC character screen resides at $0C00-$0FE7 and the colour map at $0800-$0BE7. If you load or copy into these areas something then change the content of the screen with any kind of interaction you cannot be sure that your content will not change therefore it is advised not to do anything like this.
|
|
Posted By
George on 2012-08-10 04:52:45
| Re: Combing Text and freely placeable bitmaps on screen
Hi gerliczer,
Of course, I did replace the assembly lines. And I understand the interaction with the character screen.
I save the Data again to have it as file on a disk. My far goal is to write a game, which is loaded after a Reset from a single disk. Except you know a way how to get the PRG file on a disk and load it from there.
|
|
Posted By
gerliczer on 2012-08-10 05:17:01
| Transferring files to a disk image
Well, it can be done the way you are doing it, but it is very tedious and error prone. I'd try to use either The Star Commander or one of the numerous D64 utilities to copy the data files into a disk image. Ask the nice people here to recommend a good one.
|
|
Posted By
George on 2012-08-10 05:27:45
| Re: Combing Text and freely placeable bitmaps on screen
Thanks for sharing your knowledge and your experience. You see, i am starting from no serious Plus/4 experience, which i have to earn here (besides my background as Software Developer in much higher languages). I do not know the tools and Standards yet. Therefore i am very happy, that you all take your time to guide me through here. I appreciate it very much. But i think that i am not doing bad, for the first try here... I never programmed at this very basic-level, and i am learnig very much her.
|
|
Posted By
gerliczer on 2012-08-10 06:39:06
| Re: Combing Text and freely placeable bitmaps on screen
You're welcome. We all started exactly like this and we also learned from each other and from our own errors.
|
|
Posted By
KiCHY on 2012-08-10 07:12:26
| Re: Combing Text and freely placeable bitmaps on screen
Hi George,
If you use emulator (I prefer Yape) and you're developing a disk based game then I can show you a way how to avoid saving your prg files again to disk (I assume you mean D64 files here). In Yape (and other emus as well) you can emulate a floppy drive by not only attaching a D64 file but by a complete folder. So, instead of copy all the necessary prg files onto d64 to test it, just put those prg files into a folder, then configure Yape to use that folder:
Yape/Settings/Drive 8 setup.../Drive emulation = 1551 Drive emulation (IEC level/performance mode)
Then configure the "Selected IEC drive working folder" to your game folder.
This way the file extensions of the filenames become the part of plus4 filenames. What I mean: There is a "game.prg" file in that folder. Querying DIRECTORY in Yape you can see "GAME.PRG" and can load with LOAD"GAME.PRG" command. You may adapt your code to use these modified filenames (in development time only!) or remove the file extensions.
Cheers, KiCHY
|
|
Posted By
George on 2012-08-10 12:29:47
| Re: Combing Text and freely placeable bitmaps on screen
Hi Kichy, Yape is my emulator too. Thanks for this very usefull information. You saved me from this annoying step of copying the files on a Disk-Image. Now knowing this, i could give a try to the Char-Screen-Caching. But first i have to speed up my copy-procedure with this ROM-Holy-Grail Routine. I will give Feedback.
UPDATE: Ok i understand the funktion now. It copies two Arrays of Bytes of Lspecific Lenght simultaniously. Really fast. Question: Is there an easy way to get from an Decimal-Adress the HI and LOW Parts as Decimals, without the way over converting it into Hex? Answer: LowByte(x) = x and 15 Hi Byte(x) = (x and 240) /16
|
|
Posted By
gerliczer on 2012-08-10 14:20:57
| High and low byte
Are you sure about this George? Isn't it instead like this: LowByte(x) = x and 255 HiByte(x) = (x/256) and 255?
|
|
Posted By
George on 2012-08-10 14:34:32
| Re: Combing Text and freely placeable bitmaps on screen
You are right, Master of Hexaster.
|
|
Posted By
gerliczer on 2012-08-10 14:29:55
| So it is hex numbers now
I think I know where do you want to go with this. I suggest you to pick a number of picture locations and generate the addresses belonging to all lines of them at program startup so you don't have to calculate those when loading the picture. These can't be called as freely placeable bitmaps anymore but it helps performance a bit.
|
|
Posted By
George on 2012-08-10 14:34:56
| Re: Combing Text and freely placeable bitmaps on screen
Well hier my first try and i can't see what i am doing wrong here. (the code is very Beta).
The data is in 0800. I copy 2 lines of 7 chars simultaniously to 2000. (7x11 chars picture). It draws the first two lines correctly, but when it goes to the second call i get this: Look here: http://www.patsos.de/plus4/grag5.JPG
10 IF A = 1 THEN 45 20 A = 1 : graphic 4,1: LOAD "grag",8,1
45 REM Char to $2000 from $0800 46 q = 2048 : zi =8192 50 POKE192,((q ) and 255) : POKE193,(((q)/256) and 255) // source 1 60 POKE200,((zi) and 255) : POKE201,(((zi)/256)and 255) //Destination 1 61 q=q+56 : zi = zi + 320 70 POKE169,((q ) and 255) : POKE170,(((q )/256) and 255) // Source 2 80 POKE234,((zi) and 255) : POKE235,(((zi)/256) and 255) // Destination 2 81 q=q+56 : zi = zi + 320 90 REM SETTING UP ADDITIONAL VARIABLE 100 POKE2024,55 120 REM COPYING 56 BYTES FROM CHAR-GEN 130 SYSDEC("DA4F") 140 k = k+1:if k >= 4 then end: else goto 50 run
Side-Effects of the rom-call?
|
|
Posted By
gerliczer on 2012-08-10 15:15:13
| Re: Combing Text and freely placeable bitmaps on screen
I took a quick peek at the topic with the copy routine. I said there that between two calls of the routine one must be careful to set the value of the Y register to 0 if less than 256 bytes were copied which can be done at address 2036. Try this. Maybe it will help.
|
|
Posted By
MMS on 2012-08-10 18:22:45
| Re: Combing Text and freely placeable bitmaps on screen
ehm, I think it would be easier to copy the picture to the expected destination, save it to D64 frle with monitor from the location you want (OK, it two files per picture, as color and memory map separated and these are not continuous fullscreen saves). The disadvantage is: the picture should be as wide as the whote 320 pixel screen
(hopefully it is not just bulshitting... )
|
|
Posted By
Csabo on 2012-08-10 19:26:27
| Re: Combing Text and freely placeable bitmaps on screen
MMS, that would be doable, but it would also erase all the other text/graphics/whatever is next to the 7x11 area. I'm assuming George wants to put more than one of these on the screen at a time.
The "right way" to do it in my opinion would be to store the data as GfxEdit outputs it (bitmap first, the colmap and lummap), and do a SYS to a routine, where you pass in your source memory address and the required destination coords. (The size of the bitmap would be fixed to 7x11.) I used to do basic extensions back in the day, if I recall correctly you could do a nice routine that would read additional params after the SYS, so something like this: SYS 5120, DEC("0800"), 2, 2 - this would copy from $0800 to 2,2.
|
|
Posted By
George on 2012-08-10 21:54:17
| Re: Combing Text and freely placeable bitmaps on screen
Well good news, it works, after adding this here: POKE2036,0 before SYSDEC("DA4F") And its really very, very fast, even in this state. I am hanging a little at the point when coping the color/luminace, can't find the bug, but i am really tired.
10 IF A = 1 THEN 45 20 A = 1 : graphic 4,1: LOAD "grag",8,1
45 REM Char to $2000 from $0800 46 q = 2048 : zi =8192: 50 POKE192,((q ) and 255) : POKE193,(((q)/256) and 255) 60 POKE200,((zi) and 255) : POKE201,(((zi)/256)and 255) 61 q=q+56 : zi = zi + 320 70 POKE169,((q ) and 255) : POKE170,(((q )/256) and 255) 80 POKE234,((zi) and 255) : POKE235,(((zi)/256) and 255) 81 q=q+56 : zi = zi + 320 90 REM SETTING UP ADDITIONAL VARIABLE 100 POKE2024,55:POKE2036,0 120 REM COPYING 56 BYTES FROM CHAR-GEN 130 SYSDEC("DA4F") 140 k = k+1:if k >= 6 then end: else goto 50
@MMS, Csabo: Well Csabo is of course right, when i started this, i didnt know that it will end up in this here. But its a nice challenge doing it in basic. I learned a lot in this 3 days.
I hope the result later gives me right.
|
|
Posted By
gerliczer on 2012-08-11 04:39:27
| Re: Combing Text and freely placeable bitmaps on screen
George,
If there is no more code before you start copying the luminance and colour data and you try to use variable q without any modification, then you copy from the wrong place. You see, you picture is 11 characters high which is an odd number and this ROM routine copies two vectors which is an even number. However you may try to multiply an even number with any integer the result will always be even. In your case this may mean that you copied 12*56 bytes instead of 11*56 which also may mean that you copy part of the colour data into the luminance matrix and you partly fill the colour matrix with memory garbage. But this would be only true if you not compensate for the even-odd issue. If you do then show us you code and we surely will help finding the bug.
|
|
Posted By
George on 2012-08-11 09:59:19
| Re: Combing Text and freely placeable bitmaps on screen
I seem to have Code-blindness. It seem to be, that no Col/Lum Data is copied. I see no effect.
10 IF A = 1 THEN 46 20 A = 1 : graphic 3,1: color 0,1: color 3,2: color 4,1: LOAD "grag",8,1 46 q =DEC("0800") : zi =8192: 49 for k = 0 to 5 50 POKE192,((q ) and 255) : POKE193,(((q)/256) and 255) 60 POKE200,((zi) and 255) : POKE201,(((zi)/256)and 255) 61 if k then q = q+56 : zi = zi + 320 70 POKE169,((q ) and 255) : POKE170,(((q )/256) and 255) 80 POKE234,((zi) and 255) : POKE235,(((zi)/256) and 255) 81 q=q+56 : zi = zi + 320 90 REM SETTING UP ADDITIONAL VARIABLE 100 POKE2024,55:POKE2036,0 120 REM COPYING 56 B 130 SYSDEC("DA4F") 140 next
150 k=0:q1 = DEC("0800")+770-154:q2=DEC("0800")+770-77 : 151 z1=DEC("1800"):z2= DEC("1C00") 160 POKE192,(q1 and 255) : POKE193,((q1/256) and 255) 170 POKE200,(z1 and 255) : POKE201,((z1/256)and 255) 180 q1=q1+7 : z1=z1+40 : 190 POKE169,(q2 and 255) : POKE170,((q2 /256) and 255) 200 POKE234,(z2 and 255) : POKE235,((z2 /256) and 255) 210 q2 = q2 + 7: z2 = z2 + 40 : 220 REM SETTING UP ADDITIONAL VARIABLE 230 POKE2024,6: POKE2036,0: 240 REM COPYING 77 B 250 SYSDEC("DA4F") 260 k = k+1:if k >=11 then end:else goto 160 run
|
|
Posted By
gerliczer on 2012-08-11 07:38:00
| Re: Combing Text and freely placeable bitmaps on screen
I don't see anything missing beyond setting the proper global colours like you did it before. Add e.g. this line: 30 COLOR0,1:COLOR3,2. But there is an annoying artefact at the bottom of the picture which comes from copying some luminance data into the graphic screen. You should either make your picture even number of chars high or set the source and destination addresses the same in the last (odd) ROM routine call.
|
|
Posted By
George on 2012-08-11 08:41:31
| Re: Combing Text and freely placeable bitmaps on screen
Maybe another sideeffect of the Holy Grail Procedure.
|
|
Posted By
gerliczer on 2012-08-11 09:27:12
| Re: Combing Text and freely placeable bitmaps on screen
I suggest the following modifications:
61 if k then q = q + 56 : zi = zi + 320
and delete the PRINT from line 180 and 210 because it interferes with your cached picture.
|
|
Posted By
George on 2012-08-11 09:57:01
| Re: Combing Text and freely placeable bitmaps on screen
Thanks gerliczer,
the print lines were the problem. I deleted them.
The function works and is much, much quicker now.
Whats the aquivalent of if k then ... if k <5 then..?
|
|
Posted By
gerliczer on 2012-08-11 13:30:11
| Re: Combing Text and freely placeable bitmaps on screen
IF K THEN ... equals IF K<>0 THEN ...
It is written here: http://plus4world.powweb.com/plus4encyclopedia/500203
Sorry, I will not make it into a proper link.
Edit: Don't double post, it tells me. Double post my foot.
Anyway, here are a somewhat modified version of your test program George. Sorry, I'm HTML illiterate, I can't make a link from your name as I usually do.
10 IFA=1THEN46 20 A=1:GRAPHIC4,1:LOAD"GRAG",8,1 46 Q=DEC("0800"):ZI=8192 49 COLOR0,1:COLOR3,2:PRINT"…":REM CTRL+2=WHITE 50 POKE192,QAND255:POKE193,Q/256 60 POKE200,ZIAND255:POKE201,ZI/256 61 IFKTHENQ=Q+56:ZI=ZI+320 70 POKE169,QAND255:POKE170,Q/256 80 POKE234,ZIAND255:POKE235,ZI/256 81 Q=Q+56:ZI=ZI+320 90 REM SETTING UP ADDITIONAL VARIABLE 100 POKE2024,55:POKE2036,0 120 REM COPYING 56 B 130 SYSDEC("DA4F") 140 K=K+1:IFK>=6THEN150:ELSE50 150 K=0:Q1=DEC("0800")+770-154:Q2=DEC("0800")+770-77 151 Z1=DEC("1800"):Z2=DEC("1C00") 152 POKE2022,20:POKE2024,39 159 PRINTQ1,Z1:PRINTQ2,Z2 160 POKE192,Q1AND255:POKE193,Q1/256 170 POKE200,Z1AND255:POKE201,Z1/256 180 Q1=Q1+7:Z1=Z1+40 190 POKE169,Q2AND255:POKE170,Q2/256 200 POKE234,Z2AND255:POKE235,Z2/256 210 Q2=Q2+7:Z2=Z2+40 220 REM SETTING UP ADDITIONAL VARIABLE 230 POKE2024,6:POKE2036,0 240 REM COPYING 77 B 250 SYSDEC("DA4F"):POKE2024,39 260 K=K+1:IFK>=11THENEND:ELSE159
|
|
Posted By
George on 2012-08-11 15:34:55
| Re: Combing Text and freely placeable bitmaps on screen
Hi gerliczer,
No need to make links of my name. I big thank you to you, Csabo an MMS for your kindness. I combined this and the character issue in this screenshot.
http://www.patsos.de/plus4/ThankYou.JPG
It took 28 years to make things like this on a Plus4. I had nobody to ask. Now i know why.
|
|
Posted By
MMS on 2012-08-12 16:03:58
| Re: Combing Text and freely placeable bitmaps on screen
Welcome though I could just list the problems you will face
Well, all the best for your game, and I am sure a lot of guys cross their fingers for you! The PRGs you mentioned are just great, and there are tons of nice convertable GFX from them. We badly need some quality stuff, and seeing your detials in your work I am sure it will be a nice one.
PS. Seems you are ahead in code, so I should catch up in the next days with the help of your BASIC editor
|
|
Posted By
George on 2012-08-12 16:32:51
| Re: Combing Text and freely placeable bitmaps on screen
@MMS Thank you for your kind words. Don't expect too much from me as a Game Designer. But i can tell you, i am a great story-teller. Thats why i am a fan of Snatcher and Policenauts, if you are referring to them (Besides, the guy who made this games is the same who made Metal Gear Solid). Great storys. More Interactive films, than games.
Here the the last edition of my procedure for public use (mainly for beginners like me): Five Input parameters: Pointer to Cache-Start-Adress (sa), Top-Left Position (x,y) and the dimensions (w,h) of the Bitmap. (Codeformat is from my self-written Editor, no Codelines, but with Tags). The bitmaps have the only restriction, that they should not exceed 32 chars in width (due to the Holy-Grail-function).
##LOAD_BITMAP sa=DEC("6000"): REM Pointer to Cache-Startadresse x=4:y=0 :REM Top-Left Position of Bitmap w=32:h=10 :rem Dimension Chars width/height
wb=w*8: hf=h/2: ev=((hf)-int(hf)) : if ev=0 then e=1:else e=0 if e=1 then hf=hf-1 q =sa : zi=8192 + x*8 + y*320 for k = 0 to hf POKE192,((q ) and 255) : POKE193,(((q)/256) and 255) POKE200,((zi) and 255) : POKE201,(((zi)/256)and 255) if e=1 then q = q+wb : zi = zi + 320:else e=1 POKE169,((q ) and 255) : POKE170,(((q )/256) and 255) POKE234,((zi) and 255) : POKE235,(((zi)/256) and 255) q=q+wb : zi = zi + 320 POKE2024,wb-1:POKE2036,0:SYSDEC("DA4F") next
k=0:q1 = sa+(w*h*8):q2=q1+(w*h) : z1=DEC("1800")+x+y*40:z2= DEC("1C00")+x+y*40
##COLLUMI POKE192,(q1 and 255) : POKE193,((q1/256) and 255) POKE200,(z1 and 255) : POKE201,((z1/256)and 255) q1=q1+w : z1=z1+40 : POKE169,(q2 and 255) : POKE170,((q2 /256) and 255) POKE234,(z2 and 255) : POKE235,((z2 /256) and 255) q2 = q2 + w: z2 = z2 + 40 : POKE2024,w-1: POKE2036,0:SYSDEC("DA4F") k = k+1:if k <=h then ##COLLUMI return
|
|
Posted By
Csabo on 2012-08-13 09:51:04
| Re: Combining Text and freely placeable bitmaps on screen
Good thing you got it working.
One minor optimization you could do is this: you use the variable "e" as a flag. All BASIC expressions get evaluated as an integer, -1 for TRUE and 0 for FALSE. So instead of an IF/THEN/ELSE, you could assign the value like this: "e=ev=0". (Looks a little funny, but it works.) This way, e will be -1 if ev was zero, and 0 otherwise. So you just have to change the e=1 conditions to e=-1.
You could also do z2=z1+DEC("400"), less calculations and it also makes it easier to change the luminance/color map address if needed.
|
|
Posted By
George on 2012-08-14 05:53:45
| Re: Combining Text and freely placeable bitmaps on screen
After all this time i invested in it, i made an Encyklopedia item of it, hopefully with your permission. Everybody is invited to optimize it further.
|
|
Posted By
Luca on 2012-08-14 06:10:12
| Re: Combining Text and freely placeable bitmaps on screen
Feel free to fill it with the most optimized description of what you experienced. I only deleted a clone, entered one missing date and changed the title a bit (all caps needed as title, and shorter one).
|
|
Posted By
gerliczer on 2012-11-15 06:01:25
| Re: Combining Text and freely placeable bitmaps on screen
Hi George,
How is your illustrated text adventure coming along? You seem to be fairly quiet about it nowadays.
|
|
Posted By
George on 2012-11-15 12:11:38
| Re: Combining Text and freely placeable bitmaps on screen
Hi Gerliczer,
i made a very small demo with a few pics. The problem is, that finishing only one picture costs a lot of time and results at the end into Pixel Art. We didn't found a good way for converting some selected pics.
The other thing is composing the music for it. Sounds very crappy in the way i want to do it. And i don't have found the proper notes.
But I will slowly work on my game. But the result compared to much great games here, won't be very good. My creative phases come periodically.
But thanks for asking.
Screnshot
|
|
Posted By
Csabo on 2012-11-16 10:48:18
| Re: Combining Text and freely placeable bitmaps on screen
Try as I might, I can't seem to parse this sentence: "The problem is, that finishing only one picture costs a lot of time and results at the end into Pixel Art."
Nice to see a progress pic, looks pretty intriguing actually. I hope you keep at it.
Regarding music: were you thinking of a tune that goes in the background all the time, or a series of tunes and/or sound effects, based on what's happening in the game? If it's the former, then doing it in assembly with an IRQ based player is probably your best bet. I've written music for several games/demos and would be happy to help out, if you want. The second option is doable in basic. Some of RoePipi's games do this, or some Lavina adventures also come to mind as an example.
|
|
Posted By
George on 2012-11-23 13:11:44
| Re: Combining Text and freely placeable bitmaps on screen
Hi Csabo, thanks for the feedback.
This Game would have been more a interactive story, than a classic Scott Adams Textadventure, if i had finished it.
My Idea: A good story, fine clear pictures and realy good tunes (Background melodies) are needed for that. Especially nice composed melodies are needed to set the right mood.
The pics were hard work for me, but now possible. I tried convert and import them form Bitmaps, but finally i had to redraw every Pixel with Csabis GFX tool. Very timeconsuming. Any tips are welcome.
The tunes requires talent that i don't have. You have to extract the notes and write them down. I can compose a simple tune, but thats nothing to be proud of. I want them to have 2 voices. Csabo: Of course i would accept your help for finishing a small playable Demo with a cliffhanger.
I have to admit, solving alle the technical problems exhausted me a bit and i had no enery for the creative part...
Update: Just discovered then mentioned LOD-Play from Csabo... This is exactly what i needed. Music could be possible now.
|
|
|