Union Jack / lock-down challenge, draw your country's flag..

Basic and Machine Language

Moderator: Moderators

User avatar
beamrider
Vic 20 Scientist
Posts: 1452
Joined: Sun Oct 17, 2010 2:28 pm
Location: UK

Union Jack / lock-down challenge, draw your country's flag..

Post by beamrider »

Image

Feeling bored so decided to do a little Super-Expander coding for the first time in 40 years. Please feel free to add your own country's flag to this thread.

Code:

Code: Select all

5 rem Union Jack Beamrider 05-june-2020
10 graphic 1
20 color 6,0,1,2
30 scnclr
40 h = 1024 * .65 : w = 1024: mh = h-1: mw = w-1
50 for s = mh+5 to 1024 step 6
60 draw 1,0,s to mw,s
70 next
80 wdcw  = h / 5 : u = wdcw / 6
90 for s = 0 to 3 step 0.25
100 draw 2,s*u,0 to mw, mh-s*u
110 draw 2,0,s*u to mw-s*u, mh
120 draw 2,0,mh-s*u to mw-s*u,0
130 draw 2,s*u,mh to mw,s*u
140 next s
160 for s = 0 to 2 step 0.25
170 draw 3,0,s*u to w/2, (h/2)+s*u
180 draw 3,s*u,mh to w/2, (h/2)+s*u
190 draw 3,w/2,(h/2)-s*u to mw-s*u , 0
200 draw 3,w/2,(h/2)-s*u to mw , mh - (s*u)
210 next s
220 for s = 0 to 4 step 0.15
230 draw 2,0,(h/2)+s*u to mw,(h/2)+s*u
240 draw 2,0,(h/2)-s*u to mw,(h/2)-s*u
250 draw 2,w/2+s*u ,0 to w/2+s*u ,mh
260 draw 2,w/2-s*u ,0 to w/2-s*u ,mh
270 next s
280 for s = 0 to 2 step 0.15
290 draw 3,0,(h/2)-s*u to mw,(h/2)-s*u
300 draw 3,0,(h/2)+s*u to mw,(h/2)+s*u
310 draw 3, w/2-s*u,0 to w/2-s*u,mh
320 draw 3, w/2+s*u,0 to w/2+s*u,mh
330 next s
created with CbmPrg!
User avatar
tokra
Vic 20 Scientist
Posts: 1123
Joined: Tue Apr 27, 2010 5:32 pm
Location: Scheessel, Germany

Re: Union Jack / lock-down challenge, draw your country's flag..

Post by tokra »

This is too easy :-)

Code: Select all

0 printchr$(147)chr$(18)chr$(144);:gosub2:printchr$(28);:gosub2:printchr$(158);:gosub2
1 poke198,0:wait198,1:end
2 fori=1to154:print" ";:next:return
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Union Jack / lock-down challenge, draw your country's flag..

Post by Mike »

beamrider wrote:[...] a little Super-Expander coding [...]
Wrong BASIC extension. ;)

For most flags, putting three coloured stripes on screen shouldn't be too difficult, and tokra has anyhow done it already for the German flag (Black, Red, Gold), so here's my rendition of the Union Jack in MINIGRAFIK (download):

Image

Code: Select all

1 V=36864:POKEV+14,32:POKEV+15,104:POKE646,9:@ON:@CLR
2 FORY=14TO44:@1,0,YTO159,Y+133:@1,0,Y+133TO159,Y:NEXT
3 FORY=29TO39:@3,0,YTO79,Y+66:@3,0,Y+133TO79,Y+67:NEXT
4 FORY=19TO29:@3,159,YTO80,Y+66:@3,159,Y+133TO80,Y+67:NEXT
5 FORY=73TO118:@1,0,YTO159,Y:NEXT:FORY=29TO162:@1,66,YTO92,Y:NEXT
6 FORY=82TO109:@3,0,YTO159,Y:NEXT:FORY=29TO162:@3,72,YTO86,Y:NEXT
7 FORY=0TO28:@2,0,YTO159,Y:@2,0,191-YTO159,191-Y:NEXT
8 FORP=-1TO0:GETA$:P=A$="":NEXT:@RETURN
Greetings,

Michael
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: Union Jack / lock-down challenge, draw your country's flag..

Post by chysn »

This is a bit stylized and simplistic, but so are we.
USA.png
VIC-20 Projects: wAx Assembler, TRBo: Turtle RescueBot, Helix Colony, Sub Med, Trolley Problem, Dungeon of Dance, ZEPTOPOLIS, MIDI KERNAL, The Archivist, Ed for Prophet-5

WIP: MIDIcast BASIC extension

he/him/his
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Union Jack / lock-down challenge, draw your country's flag..

Post by Mike »

This one gets the middle red stripe right:

Code: Select all

1 PRINT"{BLU,3 C=-POUND,RED,4 C=-I,C=-F}"
2 FORT=1TO3:PRINT"{BLU,3 C=-+,RED,4 C=-I,C=-F}":NEXT
3 FORT=1TO3:PRINT"{RED,7 C=-I,C=-F,BLU}":NEXT
chysn wrote:This is a bit stylized and simplistic, but so are we.
Though it may become valid on this zoom step, should the US ever grow to 336 States. :shock:

... :mrgreen:
User avatar
beamrider
Vic 20 Scientist
Posts: 1452
Joined: Sun Oct 17, 2010 2:28 pm
Location: UK

Re: Union Jack / lock-down challenge, draw your country's flag..

Post by beamrider »

Image


Here's my US one. I opted for C and made use of my screen-designer in this example. I went a bit OCD on getting the line height correct and a border around the stars.

Attached is the .prg for the unexpanded Vic and source files. I haven't tested it on real hardware so not sure if the screen geometry is correct for all displays.

Code: Select all

#include <conio.h>
#include <vic20.h>

#define NULL 0
#define FALSE 0
#define TRUE !FALSE
#define COLORRAM 0x9600
#define SCREENRAM  0x1E00
#define VERT_OFFSET 36
#define HORZ_OFFSET 8
#define COL_COUNT 26
#define LINE_COUNT 19
#define LINE_COUNT_MASK 0x81
#define COL_COUNT_MASK 0x80
#define SCREENDATA_ENDMARKER  0x40
#define SCREENDATA_RLEINDICATOR 0x80

typedef unsigned char BYTE;
typedef unsigned char BOOL;

extern BYTE ScreenData[];
extern BYTE ColourData[];

void InitVICSettings();
void plotValuesRLE(BYTE x, BYTE y, BYTE* pData, BYTE* target);

void main (void)
{
	InitVICSettings();
	plotValuesRLE(0,0,ScreenData, SCREENRAM);
	plotValuesRLE(0,0,ColourData, COLORRAM);
	while(1);
}

void InitVICSettings()
{
	BYTE tmp;

	// Set the screen colours
	textcolor (COLOR_RED);
	bordercolor (COLOR_BLACK);
	bgcolor (COLOR_WHITE);
	VIC.volume_color = (COLOR_RED << 4) | (VIC.volume_color & 0x0F);
	
	// Set the screen geometry
	VIC.addr = (VIC.addr & 0xF0) | 0x0E; // 128 chars at $1800 
	VIC.leftborder = HORZ_OFFSET;
	VIC.charsperline = (VIC.charsperline & COL_COUNT_MASK) | COL_COUNT;
	VIC.upperborder = VERT_OFFSET;
	VIC.linecount = (VIC.linecount &  LINE_COUNT_MASK) | (LINE_COUNT << 1);
}

 

void plotValuesRLE(BYTE x, BYTE y, BYTE* pData, BYTE* target)
{
	int index = 0;
	int screenIndex = 0;
	int rleCount = 0;
	BYTE rleIndex = 0;
	BYTE value = 0;
 
	
	while (pData[index] != SCREENDATA_ENDMARKER)
	{
		if (pData[index] >=  SCREENDATA_RLEINDICATOR)
		{
			value = pData[index] & ~SCREENDATA_RLEINDICATOR;
			rleCount = 1;
		}
		else
		{
			rleCount = pData[index];
			index++;
			value = pData[index];
		}

		for (rleIndex = 0; rleIndex < rleCount; rleIndex++)
 			target[screenIndex++] =  value;
		
		index++;
 
	}

}

Attachments
USFlag.zip
(4.11 KiB) Downloaded 42 times
Last edited by beamrider on Sat Jun 06, 2020 11:54 am, edited 3 times in total.
User avatar
beamrider
Vic 20 Scientist
Posts: 1452
Joined: Sun Oct 17, 2010 2:28 pm
Location: UK

Re: Union Jack / lock-down challenge, draw your country's flag..

Post by beamrider »

Mike wrote: Fri Jun 05, 2020 1:55 pm
beamrider wrote:[...] a little Super-Expander coding [...]
Wrong BASIC extension. ;)
Yes, yours is more powerful, but SE was chosen for nostalgic reasons :D
User avatar
beamrider
Vic 20 Scientist
Posts: 1452
Joined: Sun Oct 17, 2010 2:28 pm
Location: UK

Re: Union Jack / lock-down challenge, draw your country's flag..

Post by beamrider »

tokra wrote: Fri Jun 05, 2020 12:47 pm This is too easy :-)
You could always make it more difficult using raster-splits instead :D
User avatar
beamrider
Vic 20 Scientist
Posts: 1452
Joined: Sun Oct 17, 2010 2:28 pm
Location: UK

Re: Union Jack / lock-down challenge, draw your country's flag..

Post by beamrider »

Image

And here is Canada.

Same code as US but with different display data.

Code: Select all

;settings
;background-colour=1
;border-colour=0
;aux-colour=2
;rle-encoded=true
;char-height=8
;row-count=20
;col-count=24

;char data
CharData:
udc0: .byte  $07,$03,$03,$01,$00,$00,$00,$00
udc1: .byte  $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
udc2: .byte  $00,$00,$00,$00,$00,$00,$00,$00
udc3: .byte  $00,$20,$3C,$3F,$3F,$1F,$1F,$1F
udc4: .byte  $1F,$1F,$0F,$0F,$0F,$0F,$0F,$07
udc5: .byte  $07,$07,$07,$07,$03,$03,$07,$07
udc6: .byte  $1F,$3F,$7F,$7F,$3F,$1F,$1F,$0F
udc7: .byte  $01,$01,$01,$81,$F3,$FF,$FF,$FF
udc8: .byte  $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
udc9: .byte  $FF,$FF,$FF,$FF,$FF,$7F,$7F,$3F
udc10: .byte  $1F,$0F,$0F,$07,$03,$01,$01,$00
udc11: .byte  $00,$00,$00,$00,$C0,$C0,$E0,$E0
udc12: .byte  $F0,$F0,$F8,$FC,$FC,$FE,$FE,$FF
udc13: .byte  $7F,$3F,$3F,$1F,$0F,$0F,$07,$07
udc14: .byte  $0F,$0F,$0F,$0F,$1F,$1F,$1F,$1F
udc15: .byte  $1F,$38,$00,$00,$00,$00,$00,$00
udc16: .byte  $00,$00,$00,$00,$00,$80,$C0,$E0
udc17: .byte  $F0,$F8,$FC,$FF,$7F,$7F,$7F,$7F
udc18: .byte  $7F,$7F,$7F,$7F,$3F,$3F,$3F,$3F
udc19: .byte  $3F,$3F,$3F,$3F,$3F,$1F,$1F,$1F
udc20: .byte  $1F,$1F,$1F,$1F,$1F,$0F,$0F,$0F
udc21: .byte  $0F,$8F,$8F,$FF,$FF,$FF,$FF,$FF
udc22: .byte  $FF,$FF,$FF,$FF,$FF,$FF,$FF,$F0
udc23: .byte  $80,$00,$00,$00,$00,$00,$00,$00
udc24: .byte  $00,$00,$00,$00,$01,$01,$03,$03
udc25: .byte  $03,$03,$07,$07,$07,$0F,$0F,$0F
udc26: .byte  $1F,$1F,$1F,$3F,$3F,$3F,$3F,$7F
udc27: .byte  $7F,$7F,$FF,$FF,$FF,$FF,$FF,$FF
udc28: .byte  $FF,$FF,$FF,$FF,$FF,$E7,$03,$03
udc29: .byte  $03,$03,$03,$03,$03,$03,$03,$03
udc30: .byte  $03,$03,$03,$03,$07,$07,$00,$00
udc31: .byte  $80,$80,$80,$C0,$C0,$C0,$E0,$E0
udc32: .byte  $E0,$F0,$F0,$F0,$F0,$F8,$F8,$F8
udc33: .byte  $FC,$FC,$FC,$FF,$FF,$FF,$FF,$FF
udc34: .byte  $FF,$FF,$FF,$FF,$FF,$9F,$81,$00
udc35: .byte  $00,$80,$80,$80,$80,$80,$80,$80
udc36: .byte  $80,$80,$80,$80,$80,$80,$80,$80
udc37: .byte  $80,$80,$80,$80,$80,$80,$00,$00
udc38: .byte  $00,$00,$00,$00,$00,$02,$06,$0E
udc39: .byte  $1C,$3C,$7C,$FC,$FC,$FC,$FC,$FC
udc40: .byte  $FC,$F8,$F8,$F8,$F8,$F8,$F8,$F8
udc41: .byte  $F8,$F0,$F0,$F0,$F0,$F0,$F0,$F0
udc42: .byte  $F0,$F0,$E0,$E0,$E0,$E0,$E1,$E1
udc43: .byte  $E3,$E3,$E7,$FF,$FF,$FF,$FF,$FF
udc44: .byte  $FF,$FF,$FF,$FF,$FF,$FF,$FF,$3F
udc45: .byte  $03,$00,$00,$00,$00,$00,$00,$00
udc46: .byte  $00,$00,$00,$00,$04,$0C,$0E,$1E
udc47: .byte  $1E,$3E,$3F,$7F,$7F,$FF,$FF,$FF
udc48: .byte  $FF,$FF,$FF,$FF,$FF,$FF,$FE,$FE
udc49: .byte  $FC,$F8,$F0,$F0,$E0,$C0,$C0,$C0
udc50: .byte  $C0,$E0,$E0,$E0,$E0,$E0,$F0,$F0
udc51: .byte  $F0,$70,$00,$00,$00,$00,$00,$00
udc52: .byte  $00,$00,$00,$03,$1F,$FF,$FF,$FF
udc53: .byte  $FF,$FF,$FF,$FF,$FE,$FC,$F8,$F8
udc54: .byte  $F0,$E0,$C0,$C0,$80,$00,$00,$00
udc55: .byte  $00,$18,$F8,$F0,$F0,$F0,$F0,$F0
udc56: .byte  $E0,$E0,$E0,$E0,$E0,$C0,$C0,$C0
udc57: .byte  $C0,$C0,$80,$80,$80,$80,$80,$C0
udc58: .byte  $E0,$F8,$FC,$FC,$F8,$F0,$E0,$E0
udc59: .byte  $C0,$80,$00,$00,$00,$00,$00,$00
udc60: .byte  $7C,$22,$22,$3C,$22,$22,$7C,$00

;screen data0
ScreenData0:

.byte  $06,$01,$0C,$02,$0C,$01,$05,$02
.byte  $98,$06,$02,$0C,$01,$05,$02,$99
.byte  $9F,$05,$02,$0C,$01,$04,$02,$90
.byte  $9A,$A0,$A6,$04,$02,$0C,$01,$04
.byte  $02,$91,$9B,$A1,$A7,$04,$02,$0C
.byte  $01,$04,$02,$92,$02,$08,$A8,$04
.byte  $02,$0C,$01,$03,$02,$8B,$93,$02
.byte  $08,$A9,$AE,$03,$02,$0C,$01,$82
.byte  $83,$87,$8C,$94,$02,$08,$AA,$AF
.byte  $B4,$B7,$82,$0C,$01,$82,$84,$02
.byte  $08,$95,$02,$08,$AB,$02,$08,$B8
.byte  $82,$0C,$01,$82,$85,$08,$08,$B9
.byte  $82,$0C,$01,$82,$86,$08,$08,$BA
.byte  $82,$0C,$01,$82,$80,$89,$06,$08
.byte  $B5,$BB,$82,$0C,$01,$02,$02,$8A
.byte  $05,$08,$B0,$B6,$02,$02,$0C,$01
.byte  $03,$02,$8D,$04,$08,$B1,$03,$02
.byte  $0C,$01,$03,$02,$8E,$96,$9C,$A2
.byte  $AC,$B2,$03,$02,$0C,$01,$03,$02
.byte  $8F,$97,$9D,$82,$AD,$B3,$03,$02
.byte  $0C,$01,$05,$02,$9D,$A3,$05,$02
.byte  $0C,$01,$05,$02,$9D,$A4,$05,$02
.byte  $0C,$01,$05,$02,$9E,$A5,$05,$02
.byte  $0C,$01,$0C,$02,$06,$01

;colour data0
ColourDataScreen0:

.byte  $7F,$02,$7F,$02,$7F,$02,$63,$02


Attachments
CanadaFlag.zip
(1.07 KiB) Downloaded 33 times
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: Union Jack / lock-down challenge, draw your country's flag..

Post by chysn »

That's some beautiful work there. I couldn't resist giving this the minimalist treatment. I love Canada so much. We used to be able to just cross the bridge whenever we wanted. Now we have to grab our passports. Still, if you ever get a chance to get to Point Pelee to see the monarchs prep for migration, it's quite a sight.
Screen Shot 2020-06-07 at 1.23.18 AM.png
VIC-20 Projects: wAx Assembler, TRBo: Turtle RescueBot, Helix Colony, Sub Med, Trolley Problem, Dungeon of Dance, ZEPTOPOLIS, MIDI KERNAL, The Archivist, Ed for Prophet-5

WIP: MIDIcast BASIC extension

he/him/his
User avatar
beamrider
Vic 20 Scientist
Posts: 1452
Joined: Sun Oct 17, 2010 2:28 pm
Location: UK

Re: Union Jack / lock-down challenge, draw your country's flag..

Post by beamrider »

chysn wrote: Sat Jun 06, 2020 11:26 pm That's some beautiful work there. I couldn't resist giving this the minimalist treatment. I love Canada so much. We used to be able to just cross the bridge whenever we wanted. Now we have to grab our passports. Still, if you ever get a chance to get to Point Pelee to see the monarchs prep for migration, it's quite a sight.

Screen Shot 2020-06-07 at 1.23.18 AM.png
Thanks..

I like your flag too - small but perfectly formed.

Yes, Canada is great, I've been once to Toronto and visited their side of the Niagara falls.

btw, what tool are you using to enter the assembler?
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Union Jack / lock-down challenge, draw your country's flag..

Post by Mike »

beamrider wrote:btw, what tool are you using to enter the assembler?
This is chysn's own wAx, which he wrote just recently.
User avatar
beamrider
Vic 20 Scientist
Posts: 1452
Joined: Sun Oct 17, 2010 2:28 pm
Location: UK

Re: Union Jack / lock-down challenge, draw your country's flag..

Post by beamrider »

Mike wrote: Sun Jun 07, 2020 4:02 am
beamrider wrote:btw, what tool are you using to enter the assembler?
This is chysn's own wAx, which he wrote just recently.
Thanks, looks interesting, will take a look.
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: Union Jack / lock-down challenge, draw your country's flag..

Post by chysn »

beamrider wrote: Sun Jun 07, 2020 6:52 am
Mike wrote: Sun Jun 07, 2020 4:02 am
beamrider wrote:btw, what tool are you using to enter the assembler?
This is chysn's own wAx, which he wrote just recently.
Thanks, looks interesting, will take a look.
It's what happens when VICMon drives a man to the edge. It was either this or lots and lots of vodka. https://github.com/Chysn/wAx/wiki

But the work of the world continues...
japan.png
VIC-20 Projects: wAx Assembler, TRBo: Turtle RescueBot, Helix Colony, Sub Med, Trolley Problem, Dungeon of Dance, ZEPTOPOLIS, MIDI KERNAL, The Archivist, Ed for Prophet-5

WIP: MIDIcast BASIC extension

he/him/his
User avatar
aitsch
Vic 20 Amateur
Posts: 51
Joined: Sun Mar 08, 2020 12:54 pm
Location: Germany NS

Re: Union Jack / lock-down challenge, draw your country's flag..

Post by aitsch »

europe.png
not really one country 8)

Code: Select all

*=$1001
!byte $0b,$08, $e2,$07, $9e, $20, $34, $31, $31, $30, $00,$00, $00


screen=$1e49
color=$9649

; --------- init -----------
                          lda #$fe          ; custom char har at $1800
                          sta $9005         
                          
                          lda #147
                          jsr $ffd2

                          ;cpy char rom
                          ldx #1
                          ldy #0
 .rom_char                lda $8000,y                          
 .cust_char               sta $1800,y
                          lda #7
                          sta color,y
                          dey
                          bne .rom_char
                          inc .rom_char+2
                          inc .cust_char+2
                          dex
                          bpl .rom_char
                          
                          ; modify char
                          ldy #39
  .loop1                  lda char,y
                          sta $1950,y
                          dey
                          bpl .loop1
                          

!zone draw
  draw                    ; stars
                          ldy #8
  .initx                  ldx #8
  .loop                   lda flag,x
                   srn    sta screen,x
                          dex
                          bpl .loop
                          lda #9
                          adc .loop+1
                          sta .loop+1
                          lda srn+1
                          adc #22
                          sta srn+1
                          dey
                          bpl .initx
                          
                          ; Text
                          lda #0
                          sta $0286 
  .text                   ldx #16
                          ldy #0           
                          clc               
                          jsr $fff0         

                          ldx #$00          
  .loop_text              lda europe,x      
                          beq main
                          jsr $ffd2         
                          inx               
                          jmp .loop_text
                          
!zone main
main
                          lda $9004
                          cmp #88
                          bpl .color1
                          lda #105
                          bne .fill
  .color1                 lda #25
  .fill                   sta $900f
                          jmp main
                          
; --------- data
  
flag
  !text "    +    "
  !text "  * , *  "
  !text " +     + "
  !text " ,     , "
  !text ".-     .-"
  !text " +     + "
  !text " ,     , "
  !text "  * + *  "
  !text "    ,    "

europe
    !text "EUROPE"
  
char 
!byte  $00,$66,$3c,$ff,$3c,$66,$00,$00                         
!byte  $00,$00,$00,$00,$00,$66,$3c,$ff
!byte  $3c,$66,$00,$00,$00,$00,$00,$00
!byte  $00,$60,$c0,$f0,$c0,$60,$00,$00
!byte  $00,$06,$03,$0f,$03,$06,$00,$00
Post Reply