Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : PicoMite: PicoGAME VGA development
Page 25 of 31 | |||||
Author | Message | ||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4257 |
Mick, Tom, and others, Below an example of a game for the VGA picomite GAME platform. It is very elementary, but has a lot of charm in it's simplicity. The game requires the VGA picmite GAME board and 2 NES controllers. It is a two player game. You need a partner to play it. The screen shows 3 circles Blue = player A Red = player B Green is the food you need to eat to grow. Target is to grow to the size that exceeds the screen....yep that is big... You grow when you eat. You shrink when you collide into the other player...and have speed. So if you are not moving, you don't shrink. Let the other player collide into you. So blocking the food is a good tactic. You can move diagonally, and across screen borders, so surprise is easy. Me and my wife had a lot of laughter playtesting. This game is far from finished, but already nice to play. Due to Covid we where 1.5 meter appart, but due to the game...really close. Future enhancement could be to restart the game from the NES controllers. Have fun.... 'circle, a 2 player game for VGA picomite GAME 'features PIONES2 - PIO SPI for dual NES controller 'VGApicomiteGAME board revision 1.4 '---------------------------- IO pin configuration ------------------------- 'pin asignment K8/sm0 K7/sm1 'data (in) gp1 gp4 'latch (out) gp2 gp5 'clk (out) gp3 gp22 'reserve pins for PIO1 sm0 SetPin gp1,pio1:SetPin gp2,pio1:SetPin gp3,pio1 'sm0 SetPin gp4,pio1:SetPin gp5,pio1:SetPin gp22,pio1 'sm1 'power the 2 ports K8 and K7 if needed SetPin gp14,dout:Pin(gp14)=1 SetPin gp15,dout:Pin(gp15)=1 '------------------------------ PIO configuration -------------------------- 'PIO1 execute frequency f=100000 'pio config PIO1 sm0 s0=2^19 'default with IN shift left, OUT shift right p0=Pio(pinctrl 1,1,1,GP1,GP3,GP2,GP3) 'GP1=IN base GP2=SET GP3=OUT/SIDESET 'pio config PIO1 sm1 s1=2^19 'default with IN shift left, OUT shift right p1=Pio(pinctrl 1,1,1,GP4,GP22,GP5,GP22) 'GP4=IN base, GP5=SET GP22=OUT/SIDESET '------------------------------ PIO program (comment) ----------------------- 'pio1 sm0 program, identical code for sm0 and sm1, clock is side set pin 'adr/instr/comment '0 E081 'set pindir latch, out [side 0] '1 E000 'set latch low [side 0] '2 A0EB 'MOV null inverted to OSR [side 0] '3 6081 'OUT 1 bit OSR to pindirs [side 0] set clock output '4 E001 'latch high [side 0] latch pulse '5 E000 'latch low [side 0] '6 E027 'load X with value 7 [side 0] '7 A0C3 'mov NULL to ISR [side 0] '8 4001 'shift 1 bit data in ISR [side 0] '9 1048 'JMP X-- to &h8 [side 1] this is the clock pulse 'A 8000 'push ISR [side 0] 8 bits to fifo 'B 0004 'jmp to &h4 [side 0] next cycle '&h0C....&h1F not used '------------------------- END PIO program (comment) -------------------------- 'pio1 program in data statements Dim a%(7)=(&h6081A0EBE000E081,&hA0C3E027E000E001,&h0004800010484001,0,0,0,0,0) 'program and start the PIO1 state machines PIO program 1,a%() 'program PIO1 PIO init machine 1,0,f,p0,,s0,0 'init sm0 from address &h00 PIO init machine 1,1,f,p1,,s1,0 'init sm1 from address &h00 (same code) PIO start 1,0 'start PIO1 sm0 PIO start 1,1 'start PIO1 sm1 Dim h%(5) '------------------------------ MAIN level ----------------------------------- MODE 2 'initial values for the players and the target food 'target (green) index 0, left player (K8/port A/blue) index 1 'right player (K7/port B/ red) index 2 sz=MM.HRes/40 'x,y are coordinates, r=radius, c=color, s=speed x0=MM.HRes/2:y0=MM.VRes/3:r0=sz:c0=RGB(green) x1=MM.HRes/3:y1=2*MM.VRes/3:r1=sz:c1=RGB(blue):s1=5 x2=2*MM.HRes/3:y2=2*MM.VRes/3:r2=sz:c2=RGB(red):s2=5 FRAMEBUFFER create FRAMEBUFFER write f 'initial target Circle x0,y0,r0,,,c0,c0 'this is the main game loop. the gams stops when one player 'size exceeds the screen limits Do 'read the FIFO's that contain the NES controller keys PIO read 1,0,5,h%() 'read 5 words from FIFO sm0 p1=255-h%(4) 'converto to value 0-15 PIO read 1,1,5,h%() 'read 5 words from FIFO sm1 p2=255-h%(4) 'converto to value 0-15 'wipe old positions players Circle x1,y1,r1,,,0,0 Circle x2,y2,r2,,,0,0 'move players v1=0:v2=0 if (p1 and 2) then v1=v1+s1:x1=x1-s1 if (p1 and 1) then v1=v1+s1:x1=x1+s1 if (p2 and 2) then v2=v2+s2:x2=x2-s2 if (p2 and 1) then v2=v2+s2:x2=x2+s2 if (p1 and 8) then v1=v1+s1:y1=y1-s1 if (p1 and 4) then v1=v1+s1:y1=y1+s1 if (p2 and 8) then v2=v2+s2:y2=y2-s2 if (p2 and 4) then v2=v2+s2:y2=y2+s2 'allow wrap around if x1<0 then x1=x1+mm.hres if x1>mm.hres then x1=x1-mm.hres if y1<0 then y1=y1+mm.vres if y1>mm.vres then y1=y1-mm.vres if x2<0 then x2=x2+mm.hres if x2>mm.hres then x2=x2-mm.hres if y2<0 then y2=y2+mm.vres if y2>mm.vres then y2=y2-mm.vres 'calculate distances d12=Sqr((x1-x2)^2 + (y1-y2)^2) d10=Sqr((x1-x0)^2 + (y1-y0)^2) d20=Sqr((x0-x2)^2 + (y0-y2)^2) 'game rules, collision between players is punished 'player who moves is culprit If d12<(r1+r2) Then If v1>0 Then r1=r1/2 If v2>0 Then r2=r2/2 r1=max(r1,1) r2=max(r2,1) EndIf 'you eat, you grow.... If d10<(r1+r0) Then r1=r1*2 newfood EndIf If d20<(r0+r2) Then r2=r2*2 newfood EndIf 'write new player /target positions and sizes Circle x1,y1,r1,,,c1,c1 Circle x2,y2,r2,,,c2,c2 Circle x0,y0,r0,,,c0,c0 FRAMEBUFFER copy f,n,b Pause 50 Loop while r1<MM.Vres and r2<MM.vres End Sub newfood Circle x0,y0,r0,,,0,0 x0=MM.HRes*Rnd() y0=MM.VRes*Rnd() end sub end sub Edited 2022-06-27 19:27 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 4047 |
You've beat me to it @Volhout, I spent too much of yesterday playing with my RaspberryPi/MMB4L <-> PicoMite toolchain rather than making any progress on the end result. Sorry to hear about that @Volhout, hope you / your wife feel better soon. Best wishes, Tom Edited 2022-06-27 21:01 by thwill Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 4047 |
Hopefully another controller option for the PicoGAME VGA has just arrived from the Far-East: 4 directions + 6 independent fire-buttons + Start + Select Reads like an NES controller except from a 16-bit shift-register instead of an 8-bit one. Though whether you need all these buttons is debatable, the original NES version of Elite (not known for its limited number of controls) managed with just the standard NES controller. On a related note: As I understand it there are jumpers on the PCB that need to be set for NES gamepad vs. Atari joystick vs. "analogue". Is there any way an MMBasic program can determine the position of these jumpers and thus what controllers are attached (or at least what controllers the user has setup the board for) ? Best wishes, Tom Edited 2022-07-07 03:59 by thwill Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6815 |
On version 1.4: For Port A and the PicoGAME Mini For pins 1, 2, 3, 4 and 14 it's just the way you read the pins. There are no links to change. Pins 5 and 9 are connected to ADC inputs, which have 10k resistors to pull them up or down or left off depending on the type of analogue input to be used. For Port B (not fitted on the PicoGAME Mini) Pins 2,3, 4 and 15 of Port B are always connected to their GP pins. Pin 9 is always connected to GP28 Version 2.0 is slightly different for GP28 It can be linked to either Port B or to the SET pin of the JDY-40 The Port B end is connected to pin 9 as usual but has an additional link block to also connect it to pin 1, where it can act as the Up input. Pin GP28 of LB1 will normally be set to UP to connect the necessary pull-up. Because the system is so simple, and switched joysticks are always normally open, I can't think of any way for MMBasic to figure out what's fitted. I suppose you could try reading a controller with a timeout. If you don't get a data stream back within the timeout then there *may* be a switched joystick fitted. Analogue sticks / paddles can be read to see if they have a value, but they would share the same fire button as the switched joystick. Edited 2022-07-07 04:01 by Mixtel90 Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 4047 |
Gave the "SNES" controller a quick smoke-test with @Volhout's NES PIO code and it reads the first 8-bits identically (same mapping) to the "NES" controller. I imagine reading the other 8 bits (only 4 of which are used) is simply a case of changing the PIO code to read 16 bits => 2 bytes of the FIFO after every pulse of the latch instead of 8 bits => 1 byte - Nice! Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6815 |
Nice. :) It's an alternative controller anyway. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 4047 |
Hey Mick, Before I take @bigmik up on an offer to CNC me a prototype Acrylic case can you confirm (or not) that the mounting holes on the v2 board are going to be the same as those on the v1.4 board ? Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6815 |
Identical. The only thing is that the "top right" one (under JS1, in front of the level shifter) isn't used if you fit the full size SD card socket, but the pillar is still there. I've only just avoided the mounting pillars in some places so don't make them any bigger in diameter (5mm) than the original case. You should be able to find the Hammond drawing for the case. It gives exact dimensions. Edited 2022-07-13 03:20 by Mixtel90 Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 4047 |
Good news: Finally started integrating @Volhout's PIONES code with my game, works beautifully. Bad news: 2 of my 6 el-cheapo NES controllers don't send a discrete 0x8 from their UP button, they send an 0xA which is a simultaneous UP and LEFT which is no good for a game requiring precision control. It seems to be a mechanical problem because if I dismantle them, remove the plastic D-pad insert and just leave the rubber nipples (presumably with some conductive crap on the back of them) then they work properly - though I can't see anything obviously mechanically wrong; they are of extremely simple construction. I bought two batches of 4, both from the same vendor and both cosmetically identical. Both the bad ones are from the first batch. @Mixtel90 the two I sent you are also from this batch, perhaps you could test whether they are giving clear UP button presses ? Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4257 |
The PIONES 16 bit version would be like this (I cannot test since I don't have a SNES controller).So please understand this is untested code... 'PIONES16 - PIO SPI for SNES controller 'VGApicomiteGAME board revision 1.4 'Shrink version (both stamemachines run same code) '-------------------------------- IO pin configuration ------------------------- 'pin asignment K8/sm0 K7/sm1 'data (in) gp1 gp4 'latch (out) gp2 gp5 'clk (out) gp3 gp22 'reserve pins for PIO1 sm0 SetPin gp1,pio1:SetPin gp2,pio1:SetPin gp3,pio1 'sm0 SetPin gp4,pio1:SetPin gp5,pio1:SetPin gp22,pio1 'sm1 'power the 2 ports K8 and K7 if needed SetPin gp14,dout:Pin(gp14)=1 SetPin gp15,dout:Pin(gp15)=1 '--------------------------------- PIO configuration -------------------------- 'PIO1 execute frequency f=200000 '200kHz to achieve same responsiveness as 100kHz 8 bit controller 'note: the PIO program for both PIO's is the same, only the IO definition 'in the pinctrl register is different. The statemachines actually run same code 'pio config PIO1 sm0 s0=2^19 'default with IN shift left, OUT shift right p0=Pio(pinctrl 1,1,1,GP1,GP3,GP2,GP3) 'GP1=IN base GP2=SET GP3=OUT/SIDESET 'pio config PIO1 sm1 s1=2^19 'default with IN shift left, OUT shift right p1=Pio(pinctrl 1,1,1,GP4,GP22,GP5,GP22) 'GP4=IN base, GP5=SET GP22=OUT/SIDESET '------------------------------ PIO program (comment) ------------------------- --- 'pio1 sm0 program, identical code for sm0 and sm1, clock is side set pin 'adr/instr/comment '0 E081 'set pindir latch, out [side 0] '1 E000 'set latch low [side 0] '2 A0EB 'MOV null inverted to OSR [side 0] '3 6081 'OUT 1 bit OSR to pindirs [side 0] set clock output '4 E001 'latch high [side 0] latch pulse '5 E000 'latch low [side 0] '6 E02F 'load X with value 15 [side 0] <---------change no of bits to 15 '7 A0C3 'mov NULL to ISR [side 0] '8 4001 'shift 1 bit data in ISR [side 0] '9 1048 'JMP X-- to &h8 [side 1] this is the clock pulse 'A 8000 'push ISR [side 0] 16 bits to fifo 'B 0004 'jmp to &h4 [side 0] next cycle '&h0C....&h1F not used '------------------------- END PIO program (comment) -------------------------- - 'pio1 program in data statements Dim a%(7)=(&h6081A0EBE000E081,&hA0C3E02FE000E001,&h0004800010484001,0,0,0,0,0) 'program and start the PIO1 state machines PIO program 1,a%() 'program PIO1 PIO init machine 1,0,f,p0,,s0,0 'init sm0 from address &h00 PIO init machine 1,1,f,p1,,s1,0 'init sm1 from address &h00 (same code) PIO start 1,0 'start PIO1 sm0 PIO start 1,1 'start PIO1 sm1 '------------------------------ MAIN level ----------------------------------- Print "running" dim h%(4) 'read the FIFO's that contain the NES controller keys Do PIO read 1,0,5,h%() 'read from FIFO sm0 Print Hex$(65535-h%(4)), 'print value PIO read 1,1,5,h%() 'read from FIFO sm1 Print Hex$(65535-h%(4)) 'print value Pause 100 Loop While Inkey$="" End Edited 2022-07-13 15:57 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6815 |
They are both reasonably accurate, Tom. One has a tendency to sometimes go a bit south-east rather than south, but the other is fine. UP isn't a problem on either of them. Will the joystick button moulding rotate round to a different position? I've not had either of these to bits. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 4047 |
Thanks @Volhout, I will try and give it a spin this evening. That's good; I'm glad I didn't send you a pair of EDIT: LEMONS, not MELONS . It will, but it didn't seem to make a significant difference when I played with it briefly last night. I need to give it a proper poke and also try mixing and matching parts between the working and non-working devices. I'm currently thinking about how a program can determine what if any controllers are being used on startup - so that they can be used to navigate the game menus before the user has a chance to actually choose a controller type through the game. - The hardware doesn't allow us to determine what controllers are attached, at least not without trying to read them and asking the user to try various input actions. - Unlike the CMM2 the PicoMite firmware doesn't support flags to RUN so the user can't specify it that way. My current plan, unless someone can suggest something better is that a PicoGAME VGA aware program should check for a file named "PicoGAME.ini" in the root directory of the SD card. This will have the format: # <type> can be one of "none", "nes", "snes" or "atari" # without the quotes. port-a=<type> port-b=<type> If the file or any value within it is missing then "none" should be assumed. I'll write some standard code to read this file. Ultimately we would have a utility "pgconfig.bas" to create and update this file and allow the user to test their controllers. Possibly it could expand to do other things as we go along. Any thoughts ? Tom Edited 2022-07-13 19:14 by thwill Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4257 |
!@#$%^ I was again kicked out of the forum while typing a long explaining post. It is becoming a real annoyance. So this time short: @Tom, PIONES16 should also support NES (as well as SNES) only the keys will have different values. But the keys between NES and SNES should match. So PIONES16 could be a universal protocol. You can always program PIO1 and configure PIO1. Only defer the SETPIN xx,PIO1 and the PIO START until you are sure you configure for a NES or SNES controller. I do not think I can write a PIO1 block for ATARI. The pins on K7 are simply not compliant with the way PIO works. Please do ATARI in basic (it is simple enough). Volhout P.S. if we ever plan to make changes to the board, then I would suggest to map the pins in such a way that we can use SPI for K7 and K6. PIONES is only created becuse SPI cannot. I am 100% convinced the NES and SNES controllers can simply be ready by SPI (I have already proven it in with picomite alpha27, 1 years ago). Only the wiring between pico and K7/K6 is not correct for the pico's hardware SPI. Edited 2022-07-13 19:17 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6815 |
I like the idea of pgconfig.bas. It could also read the ADC ports to check the current positions of LB1. If Autorun was used to bring up an intro screen / menu as standard then that could read picogame.ini and give the option to run pgconfig.bas. Perhaps a cut-down version of the test program too? Just a thought. EDIT: Could it check for the presence of SYSTEM I2C as well? If that's present then GP26 and GP27 are required for that anyway so aren't available to the ADC. I suspect the pins will be RESERVED on boot. Edited 2022-07-13 20:15 by Mixtel90 Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4257 |
@Tom, Mick, I can confirm that PIONES16 works with 8 bit NES controllers. The response is a 16 bit number, where the 8 MSB are the NES buttons. The 8 LSB should be ignored, as they should represent SNES keys. Regards, Volhout P.S. What thread do you want to continue development in. The 2.0 thread ? Or this thread. Edited 2022-07-14 15:28 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6815 |
The 2.0 thread is only for that version. Development on 2.0 is finished and I probably won't be making any hardware changes unless it turns out that there is a PCB error somewhere. This is a more general thread, I think, and it's been used for development since the beginning so it might be better to keep the dev stuff on here. :) Pin allocations for the ports has generally been based on where I can get traces to and from. :) You have to bear in mind that the VGA and PS/2 connections are fixed. Port B has been allocated as a COM port since the beginning so two of its pins need to do that. I don't suppose it really matters which COM port or which pins are used as it can't take a standard DB9F RS-232 lead anyway. I need a PWM pair for the audio, but, once again, it doesn't really matter which. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 4047 |
Thanks @Volhout that's very convenient, good work. For the moment I've disappeared down a different rabbit hole but hopefully I will dig my way out by the end of the weekend so I can take a look at this. It's good to have it all together, especially when I need to trawl it for content for the Wiki. Perhaps if we ask very nicely @Gizmo may agree to rename this thread to include the canonical PCB name, perhaps "PicoGAME VGA development". Thoughts ? Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6815 |
That would be ideal, if it can be done. (I've got my software hat on at the moment. I'm actually attempting to write some sort of a game. Not something I've really attempted before, although I've modified several and copied a lot more from books & magazines over the years.) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 4047 |
We can but ask. I've sent him a PM asking for it to be named "PicoMite: PicoGAME VGA development", I thought it should still have "PicoMite" in the title as it is just a variant. Nice. With regards my game, I keep getting distracted by writing/updating my development tools whenever I hit an inconvenience rather than just working around the issue as quickly as possible. It's the Professional Software Engineer in me, but it will only pay-back if I do a lot of subsequent MMBasic development - fingers crossed. Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4257 |
@Tom, In line with the capabilities of the picomite VGA, I tried to improve the SSTV program by blitting 3x3 sprites in stead of drawing individual pixels for option 6. This is 25% faster, which I have compensated in the pause statement. I am also developing a version of the PIO demodulator that only PUSH-es data on request of the MMBasic program in stead of filling the fifo with data that may not be used. This version is still WIP. Both changes are more efficient, but actually... they do not result in a better video representation. Anyway...it is a playground for SSTV. The code still needs cleaning up... 'SSTV decoder program for ROBOT-8 mode for PICOMITE MMBasic Option default integer MODE 1 'pio program measure overlapping rising and falling period and send to FIFO 'loops increment both X and Y, alternating X and Y are reset and pushed. '0 E020 'set X=0 '1 A029 'X -> fffffff '2 00C5 'jmp (pin=1) to loop2 '3 0084 'Y-- (first loop Y contains rubbish) '4 0042 'count X-- loop1 '5 A0CA 'mov -Y to ISR '6 8000 'push noblock //nopush A042 = MOV Y,Y '7 E040 'set Y=0 '8 A04A 'Y -> fffffff '9 004A 'count X-- loop2 'A 008B 'Y-- 'B 00C9 'jmp (pin=1) in loop2 'C A0C9 'mov -X to ISR 'D 8000 'push noblock //nopush A042 = MOV Y,Y 'E 0000 'jmp 0 (rest is filled with 0 = jmp->0) 'SSTV reference Dim a%(7)=(&h008400C5A029E020,&hE0408000A0CA0042,&h00C9008B004AA04A,&h8000A0C9,0,0,0,0) 'SSTV nopush 'Dim a%(7)=(&h008400C5A029E020,&hE040A042A0CA0042,&h00C9008B004AA04A,&hA042A0C9,0,0,0,0) f=3e6 '3MHz @ 3cycles per loop = 1us per tick 'configure pio1 e=Pio(execctrl 0,0,&h1f) 'use gp0 for PIN s=Peek(word &h503000d0) 'use old value p=0 'no GPxx pins for PIO1 'program pio1 and start PIO program 1,a%() PIO init machine 1,0,f,p,e,s PIO start 1,0 'pio fifo register ff=&h50300020 'sstv specific frequecies converted to time in us l=1e6/1100 'sync low r=1e6/1200 'sync u=1e6/1300 'sync high b=1e6/1500 'black v=1e6/1900 'black/white threshold w=1e6/2300 'white menu: CLS Print "SSTV Robot-8 playground":Print Print "1 = measure frequency" Print "2 = waterfall" Print "3 = picture in burst mode (no hsync)" Print "4 = picture monochrome" Print "5 = picture in 4 green levels" Print "6 = picture in dithered white" Print "7 = stop" Do kn$=Inkey$ Loop Until kn$<>"" Select Case Val(kn$) Case 1 GoSub frequency Case 2 GoSub waterfall Case 5 GoSub greenvideo Case 3 GoSub videobrute Case 6 GoSub greyvideo Case 4 GoSub video Case 7 End End Select GoTo menu frequency: 'measure time and convert to frequency Do cnt=Peek(word ff) 'read fifo pio 1 seq 0 period = cnt+3 'period Print @(300,240) Int(1e6/period);" Hz " Pause 100 Loop While Inkey$="" Return waterfall: 'show frequency graph on horizontal axis, scolling down CLS Do Text 1,1,"frequency (Hz)","LT" Text r/2,1,"1200","CT" Text b/2,1,"1500","CT" Text w/2,1,"2300","CT" Line u/2,20,u/2,479 Line l/2,20,l/2,479 For y=20 To 479 'poke word &h503000d8,&h8000 'push 'pause 0.020 cnt=Peek(word ff) Pixel cnt/2,y,1 Pause 0.5 'delay to slow waterfall Next y CLS Loop While Inkey$="" Return video: 'video decode using both hsync and vsync 're-syncing every line and frame Do 'CLS y=180 Do x=240 Timer =0 'pixel video read an display Do Pause 0.3 'horizontal timing x=Min(390,x+1) p=Peek(word ff) Pixel x,y,(p<v) Loop Until p>u And Timer>58 Timer =0 'hsync detect > 3.5ms, vsync > 10ms Do Pause 0.3 'lower misses syncs p=Peek(word ff) Loop Until p<u And Timer>3.5 If Timer > 10 Then Exit Inc y Loop Loop While Inkey$="" Return videobrute: 'video decode fixed timing from vertical sync brute: 'find vsync Do Do p=Peek(word ff) Loop Until p>u Timer =0 Do p=Peek(word ff) Loop Until p<b Loop Until Timer > 10 'brute force process all pixels and hsync equally For y=180 To 298 For x=240 To 359 p=Peek(word ff) Pixel x,y,(p<v) Pause 0.487 Next x Next y If Inkey$="" Then GoTo brute Return greenvideo: 'video decode in mode 2 using 4 level green 're-syncing every line and frame MODE 2 Dim c%(3)=(0,&h4000,&h8000,&hC000) '3 green levels and black Do CLS y=50 Do x=80 'capture pixel data and display Timer =0 Do Pause 0.3 'rough horizontal timing x=Min(220,x+1) p=Peek(word ff) i=(p<580)+(p<522)+(p<470) Pixel x,y,c%(i) Loop Until p>u And Timer>60 Timer =0 'detect end of hsync to start new line Do p=Peek(word ff) Loop Until p<b And Timer>4 If Timer > 10 Then Exit 'sync is vsync Inc y Loop Loop While Inkey$="" MODE 1 Return greyvideo: 'create greyscale out of 3x3 tiles in B/W pixels 're-syncing every line and frame CLS 'create 10 3x3 sprites make_dither Do y=50 Do x=100 'dither pixels by blit of 3x3 sprite Timer =0 Do Pause 0.24 x=Min(500,x+3) p=Peek(word ff) n=min(max((640-p)/22,0),9) 'convert to sprite index blit 0,40+(3*n),x,y,3,3 Loop Until p>u And Timer>60 Timer =0 Print @(0,0) x 'detect end of hsync to start new line Do p=Peek(word ff) Loop Until p<u And Timer>3.5 If Timer > 10 Then Exit 'sync is a vsync Inc y,3 Loop Until y>407 Loop While Inkey$="" Return sub make_dither 'create 10 3x3 dither sprites that are blit onto the screen in stead of drawing pixels x=0:y=40 'black = do nothing y=y+3 '1 pixel pixel x+1,y+1 y=y+3 '2pixels pixel x,y:pixel x+2,y+2 y=y+3 '3pixels pixel x,y:pixel x+1,y+2:pixel x+2,y+1 y=y+3 '4pixels pixel x,y+1:pixel x+1,y:pixel x+1,y+2:pixel x+2,y+1 y=y+3 '5pixels pixel x,y:pixel x,y+2:pixel x+1,y+1:pixel x+2,y:pixel x+2,y+2 y=y+3 '6 pixels pixel x,y:pixel x,y+1:pixel x+1,y+1 pixel x+1,y+2:pixel x+2,y:pixel x+2,y+2 y=y+3 '7pixels pixel x,y:pixel x,y+1:pixel x,y+2:pixel x+1,y+1 pixel x+1,y+2:pixel x+2,y:pixel x+2,y+2 y=y+3 '8pixels pixel x,y:pixel x,y+1:pixel x,y+2:pixel x+1,y+1 pixel x+1,y+2:pixel x+2,y:pixel x+2,y+1:pixel x+2,y+2 y=y+3 '9pixels box x,y,3,3,1,1,1 end sub Edited 2022-07-16 05:41 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
Page 25 of 31 |
Print this page |