How to resolve the algorithm Hello world/Graphical step by step in the Commodore BASIC programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Hello world/Graphical step by step in the Commodore BASIC programming language

Table of Contents

Problem Statement

Display the string       Goodbye, World!       on a GUI object   (alert box, plain window, text area, etc.).

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Hello world/Graphical step by step in the Commodore BASIC programming language

Source code in the commodore programming language

1 rem hello world on graphics screen
2 rem commodore 64 version

10 print chr$(147): print " press c to clear bitmap area,"
15 print " any other key to continue"
20 get k$:if k$="" then 20
25 if k$<>"c" then goto 40

30 poke 53280,0:print chr$(147):print " clearing bitmap area... please wait..."
35 base=8192:for i=base to base+7999:poke i,0:next

40 print chr$(147);
45 poke 53272,peek(53272) or 8:rem set bitmap memory at 8192 ($2000)
50 poke 53265,peek(53265) or 32:rem enter bitmap mode

55 rem write text to graphics at tx,ty
60 t$="goodbye, world!":tx=10:ty=10
65 gosub 400

70 rem draw sine wave - prove we are in hi-res mode
75 for x=0 to 319:y=int(50*sin(x/10))+100:gosub 500:next

80 rem wait for keypress
85 get k$:if k$="" then 85

90 rem back to text mode, restore colors, end program
95 poke 53265,peek(53265) and 223:poke 53272,peek(53272) and 247
100 poke 53280,14:poke 53281,6:poke 646,14
200 end

400 rem write text to graphics routine
405 tx=tx+(40*ty):m=base+(tx*8)
410 poke 56334,peek(56334) and 254 : rem turn off keyscan
415 poke 1,peek(1) and 251 : rem switch in chargen rom
420 for i=1 to len(t$)
425 l=asc(mid$(t$,i,1))-64:if l<0 then l=l+64
430 for b=0 to 7
435 poke m,peek(53248+(l*8)+b)
440 m=m+1
445 next b, i
450 poke 1,peek(1) or 4 : rem switch in io
455 poke 56334,peek(56334) or 1 : rem restart keyscan
460 return

500 rem plot a single pixel at x,y
510 mem=base+int(y/8)*320+int(x/8)*8+(y and 7)
520 px=7-(x and 7)
530 poke mem,peek(mem) or 2^px
540 return

  

You may also check:How to resolve the algorithm Combinations with repetitions step by step in the Haskell programming language
You may also check:How to resolve the algorithm Unprimeable numbers step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Loops/Infinite step by step in the NS-HUBASIC programming language
You may also check:How to resolve the algorithm String length step by step in the UNIX Shell programming language
You may also check:How to resolve the algorithm Magic 8-ball step by step in the Perl programming language