C64U UCI HTTP BASIC EXAMPLE BASIC program example for the C64U (Commodore 64 Ultimate) interface that demonstrates how to perform an HTTP GET request. The code constructs a request to httpbin.org, opens a TCP connection, sends the request, and reads the JSON response body. It includes subroutines for locating the UCI (Ultimate Command Interface) hardware, mapping PETSCII characters to ASCII, and handling network communication errors. c64http.bas This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters 10 rem c64u uci http query tester v1.6 20 print chr$ 147 :poke646,1:print "c64u uci http qry v1.6" 30 rem c is command bytes, d is uci reply bytes 40 dim c 260 ,d 260 :dc=260 50 rem endpoint pieces: httpbin echoes query in json args 60 hn$="httpbin.org":qp$="codex=basic&uci=1" 70 pa$="/get?"+qp$:ag$="c64u-basic/1.0" 80 rem find uci, identify network target, open tcp 90 gosub 1000:if er then end 100 co=3:m$="uci base "+str$ ba :gosub 900 110 co=7:m$="identify network":gosub 900 120 c 0 =3:c 1 =1:cl=2:gosub 3000 130 if er then co=2:m$="identify failed "+s$:gosub 900:end 140 co=5:m$="network target ok":gosub 900 150 co=7:m$="open tcp "+hn$+":80":gosub 900 160 c 0 =3:c 1 =7:c 2 =80:c 3 =0:cl=4 170 q$=hn$+chr$ 0 :gosub 2000 180 gosub 3000 190 if er then co=2:m$="open failed "+s$:gosub 900:end 200 if dl<1 then co=2:m$="no socket id":gosub 900:end 210 so=d 0 :co=5:m$="socket "+str$ so :gosub 900 220 rem build readable http request from strings 230 co=7:m$="build http request":gosub 900 240 rq$="GET "+pa$+" HTTP/1.1"+chr$ 13 +chr$ 10 250 rq$=rq$+"Host: "+hn$+chr$ 13 +chr$ 10 260 rq$=rq$+"User-Agent: "+ag$+chr$ 13 +chr$ 10 270 rq$=rq$+"Accept: / "+chr$ 13 +chr$ 10 280 rq$=rq$+"Connection: close"+chr$ 13 +chr$ 10 +chr$ 13 +chr$ 10 290 rem write socket command: target 3, command 17, socket, payload 300 co=7:m$="send http request":gosub 900 310 c 0 =3:c 1 =17:c 2 =so:cl=3 320 q$=rq$:gosub 2000:wr=cl-3 330 gosub 3000 340 if er then co=2:m$="write failed "+s$:gosub 900:gosub 7000:end 350 if dl<2 then co=2:m$="write reply short":gosub 900:gosub 7000:end 360 ac=d 0 +256 d 1 370 if ac