{ ********************************************** Cordic Crickets Demo 2.20 - P2 Eval board An experiment in autonomous navigation Ozpropdev 26th December 2018 ********************************************** PIN SIGNAL --------------- basepin Hsync +1 Blue +2 Green +3 Red +4 Vsync --------------- } con basepin = 16 'basepin = %xxxx00 (0,4,8,12...) crickets = 25 no_trails = 0 osc = 20_000_000 dv = 40 mlt = 360 'for 180 MHz clk = 1 << 24 | (dv-1) << 18 | (mlt-1) << 8 sys_clk = osc / dv * mlt rx_pin = 63 tx_pin = 62 baudrate = 115_200 clocksperbit = float(sys_clk) / float(baudrate) nco = round(clocksperbit * 65536.0) & $FFFFFC00 #$c0 mode_address overrides #0 mode_trails mode_biv edge = 10 size = 1 trail_length = 150 init_radius = 120 body_points = 50 body_radius = 8 * size head_points = 30 head_radius = 5 * size feeler_length = 25 * size feeler_angle = 25 leg_length = 10 * size speed = 0 move_step = 1 edge_angle = 3 * 10 react_angle = 10 * 10 react_range = 170 * size rr = ((react_range / 5)*2)*sx cw = edge_angle * 10 ccw = (360 - edge_angle) * 10 #0 _color _body_x _body_y _heading _head_x _head_y _left_feeler_x1 _left_feeler_y1 _left_feeler_x2 _left_feeler_y2 _right_feeler_x1 _right_feeler_y1 _right_feeler_x2 _right_feeler_y2 _closest_bug _entries 'flags #0 _crickets_in_view h_size = 640 v_size = 480 scale = 8 sx = 1 << scale fclk = float(sys_clk) fpix = 25_175_000.0 fset = (fpix / fclk * 2.0) * float($4000_0000) intensity = 80 '0..128 vsync = basepin +4 'vsync pin (all FPGA boards now) tx = 62 rx = 63 #0 video_cog plot_cog main_cog plot2_cog plot3_cog text_cog = 6 comms_cog = 7 '0000000000000000000000000000000000000000000000000000000000000000 dat org hubset ##clk | %1111_01_00 'enable crystal+PLL, stay in 20MHz+ mode waitx ##20_000_000/100 'wait ~10ms for crystal+PLL to stabilize hubset ##clk | %1111_01_11 'now switch to PLL running at 80MHz coginit #plot_cog,##@plot_boot coginit #main_cog,##@main coginit #plot2_cog,##@plot2_boot coginit #comms_cog,##@comms coginit #plot3_cog,##@plot3_boot coginit #text_cog,##@vector_text wrlong #0,#overrides mov spdx,#0 setxfrq ##round(fset) 'set transfer frequency to 25MHz wrlut ##$00001000,#0 'black wrlut ##$ff000000,#1 'red wrlut ##$00ff0000,#2 'green wrlut ##$0000ff00,#3 'blue wrlut ##$ffff0000,#4 'yellow wrlut ##$00ffff00,#5 'cyan wrlut ##$ff00ff00,#6 'magenta wrlut ##$ffffff00,#7 'white wrlut ##$7fff7f00,#8 'light green wrlut ##$ff7f7f00,#9 'pink wrlut ##$7f7fff00,#10 'light blue wrlut ##$ffcf7f00,#11 wrlut ##$cf7fff00,#12 wrlut ##$7fffcf00,#13 wrlut ##$7fcfff00,#14 wrlut ##$cfff7f00,#15 setcy ##intensity << 24 'r set colorspace for rgb setci ##intensity << 16 'g setcq ##intensity << 08 'b setcmod #%01_0_000_0 'enable colorspace conversion (may be commented out) wrpin dacmode_s,#basepin 'enable dac modes in pins 0..3 wrpin dacmode_c,#basepin+1 wrpin dacmode_c,#basepin+2 wrpin dacmode_c,#basepin+3 dirh #basepin dirh #basepin+1 dirh #basepin+2 dirh #basepin+3 wrbyte #0,#0 field rdbyte pa,#0 wz bitz pa,#0 wrbyte pa,#0 cogatn #|< plot_cog | |< main_cog if_z rdfast ##(h_size/2)*v_size/64,##video_buffer0 if_nz rdfast ##(h_size/2)*v_size/64,##video_buffer1 mov x,#33 'top blanks call #blank mov x,#480 '#v_size 'set visible lines line call #hsync 'do horizontal sync xcont m_rf,#0 'visible line djnz x,#line 'another line? mov x,#10 'bottom blanks call #blank drvnot #vsync 'sync on mov x,#2 'sync blanks call #blank drvnot #vsync 'sync off jmp #field 'loop blank call #hsync 'blank lines xcont m_vi,#0 _ret_ djnz x,#blank hsync xcont m_bs,#0 'horizontal sync xcont m_sn,#1 _ret_ xcont m_bv,#0 dacmode_s long %0000_0000_000_1011000000000_01_00000_0 'hsync is 123-ohm, 3.3V dacmode_c long %0000_0000_000_1011100000000_01_00000_0 'R/G/B are 75-ohm, 2.0V m_bs long $CF000000+16 'before sync m_sn long $CF000000+96 'sync m_bv long $CF000000+48 'before visible m_vi long $CF000000+640 'h_size 'visible m_rf long $6F000000+640 'h_size 'visible rlong 4bpp lut x res 1 y res 1 ' '22222222222222222222222222222222222222222222222222222222222222222222222222 orgh $400 org main mov main,#1 cmp main,#no_trails wz mov pa,#|< mode_trails if_e mov pa,#0 wrlong pa,#mode_address call #init_constants wrlut ##-1,#0 mov spdx,#0 waitx ##sys_clk * 5 ddd waitatn incmod spdx,#speed wz if_nz jmp #ddd mov qx,#crickets-1 mov lutx,#0 ccc mov selected_bug,qx call #get_bug_info 'Screen edge detect and react mov react,#0 cmps lfx2,##edge * sx wcz if_b mov react,##cw if_b jmp #rrr cmps lfy2,##edge*sx wcz if_b mov react,##cw if_b jmp #rrr cmp lfx2,##(h_size-edge) * sx wcz if_a mov react,##cw if_a jmp #rrr cmp lfy2,##(v_size-edge) * sx wcz if_a mov react,##cw if_a jmp #rrr cmps rfx2,##edge*sx wcz if_b mov react,##ccw if_b jmp #rrr cmps rfy2,##edge*sx wcz if_b mov react,##ccw if_b jmp #rrr cmp rfx2,##(h_size-edge) * sx wcz if_a mov react,##ccw if_a jmp #rrr cmp rfy2,##(v_size-edge) * sx wcz if_a mov react,##ccw tjnz react,#rrr 'turn away from screen edge 'check stats of other crickets $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ qfrac crickets_heading,_3600 mov distance,##-1 mov sel_bug2,#crickets-1 bitl flags,#_crickets_in_view getqx hd2 loopk cmp selected_bug,sel_bug2 wz if_e jmp #next_bug 'skip if same bug# 'get bug stats loc ptrb,#@crickets_data mov tmp,sel_bug2 mul tmp,#4 * _entries add ptrb,tmp rdlong bug2x,ptrb[_body_x] rdlong bug2y,ptrb[_body_y] sub bug2x,head_x sub bug2y,head_y qvector bug2x,bug2y getqx pa 'distance to bug getqy pb 'angle 'is bug in forward view qdiv pb,_1deg getqx angle2 sub angle2,crickets_heading wc wrc direction abs angle2 cmp angle2,##1800 wcz if_a subr angle2,_3600 cmp angle2,##feeler_angle * 10 wcz if_be jmp #c_i_v jmp #next_bug 'not in v'iew 'save if closest in view c_i_v cmp pa,distance wcz 'is bug closest so far? if_ae jmp #next_bug mov dir2,direction mov distance,pa mov angle,pb mov closest_bug,sel_bug2 bith flags,#_crickets_in_view next_bug djnf sel_bug2,#loopk testb flags,#_crickets_in_view wc if_c wrlut angle,lutx 'save data for cog#3 if_c add lutx,#1 if_c wrlut head_x,lutx if_c add lutx,#1 if_c wrlut head_y,lutx if_c add lutx,#1 mov react,#0 testb flags,#_crickets_in_view wc if_nc jmp #mmm 'is bug in range? cmp distance,##react_range*sx wcz if_a jmp #mmm 'calculate proportional reaction mov tmp,distance subr tmp,##react_range*sx qmul tmp,##react_angle * 10 getqx react qdiv react,##react_range*sx mov tmp,crickets_heading sub tmp,angle wc wrc direction abs tmp getqx react turn_away testb dir2,#0 wc if_nc subr react,_3600 mmm rdlong tmp,#overrides testb tmp,qx wc 'bug paused if_c jmp #no_move tjz react,#no_edge 'no turn required 'turn away from edge or bug rrr add crickets_heading,react cmp crickets_heading,_3599 wcz if_a sub crickets_heading,_3600 cmps crickets_heading,#0 wcz if_b add crickets_heading,_3600 call #calc_bug no_edge call #move_bug no_move mov selected_bug,qx call #get_bug_info call #calc_bug all_done djnf qx,#ccc wrlut ##-1,lutx 'mark end of list incmod trail_index,#trail_length-1 jmp #ddd trail_index long 0 direction long 0 lutx long 0 dir2 long 0 spdx long 0 '========================================================== move_bug qfrac crickets_heading,_3600 getqx hd2 qrotate ##move_step*sx,hd2 getqx temp_x getqy temp_y add crickets_x,temp_x add crickets_y,temp_y wrlong crickets_x,ptra[_body_x] wrlong crickets_y,ptra[_body_y] wrlong crickets_heading,ptra[_heading] 'update trail data qmul qx,##trail_length * 4 loc pb,#@trails mov pa,trail_index shl pa,#2 '*4 add pb,pa getqx pa add pb,pa sar crickets_y,#scale sar crickets_x,#scale setword crickets_y,crickets_x,#1 wrlong crickets_y,pb ret '1111111111111111111111111111111111111111111111111111111111111111111111111111 orgh org plot_boot long 0 call #init_constants call #init_crickets call #calc_circles plot_loop waitatn call #clearscreen cogatn #|< plot2_cog | |< plot3_cog | |< text_cog call #show_crickets jmp #plot_loop plot cmps x1,##h_size-1 wcz if_a ret cmps y1,##v_size-1 wcz if_a ret testb x1,#31 wc testb y1,#31 orc if_c ret mov y9,y1 mul y1,#h_size/2 mov x9,x1 mov ptrb,current_buffer testb x1,#0 wc shr x1,#1 add ptrb,x1 add ptrb,y1 rdbyte tempr,ptrb mov x1,x9 mov y1,y9 if_nc setnib tempr,color,#0 if_c setnib tempr,color,#1 wrbyte tempr,ptrb ret 'plot line from x1,y1 to x2,y2 in current color plot_line mov x5,x1 mov y5,y1 mov x1,x2 mov y1,y2 call #plot 'set_pixel mov y1,y5 mov x1,x5 mov x_inc,#1 mov y_inc,#1 mov width,x2 subs width,x1 abs width wc 'get width negc x_inc mov height,y2 subs height,y1 abs height wc 'get height negc y_inc cmp width,height wcz if_b jmp #.pl2 'x > y and width,##$ffff wz if_z mov width,#1 shl height,#10 '*1924 mov temp2,#0 qdiv height,width getqx temp .pl1 call #plot 'set_pixel add x1,x_inc add temp2,temp cmp temp2,_1023 wcz if_a add y1,y_inc if_a sub temp2,_1024 djnz width,#.pl1 ret 'y > x .pl2 and height,##$ffff wz if_z mov height,#1 shl width,#10 '*1024 mov temp2,#0 qdiv width,height getqx temp .pl2a call #plot 'set_pixel add y1,y_inc add temp2,temp cmp temp2,_1023 wcz if_a add x1,x_inc if_a sub temp2,_1024 djnz height,#.pl2a ret orgf $1a0 _3600 long 3600 _3599 long 3599 _1000 long 1000 _1deg long 0 _1024 long 1024 _1023 long 1023 crickets_heading long 0 heading long 0 lut_index long 0 bug_color long 0 hd2 long 0 spacing long 0 spc2 long 0 count long 0 count2 long 0 crickets_x long 0 crickets_y long 0 temp_x long 0 temp_y long 0 kx long 0 ky long 0 kh long 0 loop_count long 200 qx long 0 selected_bug long 0 head_x long 0 head_y long 0 leg_count long 0 sa long 0 sa2 long 0 tmp long 0 react long 0 sel_bug2 long 0 bug2x long 0 bug2y long 0 distance long 0 angle long 0 closest_bug long 0 height long 0 width long 0 x_inc long 0 y_inc long 0 flags long 0 angle2 long 0 radius res 1 points res 1 tempr res 1 x1 res 1 y1 res 1 x2 res 1 y2 res 1 x9 res 1 y9 res 1 temp res 1 temp2 res 1 lfx1 res 1 lfy1 res 1 lfx2 res 1 lfy2 res 1 rfx1 res 1 rfy1 res 1 rfx2 res 1 rfy2 res 1 color res 1 xcount res 1 fa2 res 1 current_buffer res 1 x5 res 1 y5 res 1 mode res 1 'HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH orgh init_constants mov _3600,##3600 qfrac #1,_3600 mov _3599,##3599 mov _1000,##1000 mov _1024,##1024 mov _1023,##1023 getqx _1deg ret clearscreen rdbyte pa,#0 wz if_z loc ptra,#@video_buffer0 if_nz loc ptra,#@video_buffer1 mov current_buffer,ptra setq ##(h_size/8)*v_size _ret_ wrlong #0,ptra calc_circles mov radius,##body_radius * sx mov points,#body_points mov lut_index,#0 call #calc_circle mov radius,##head_radius * sx mov points,#head_points mov lut_index,#body_points*2 call #calc_circle ret get_bug_info call #bug_address rdlong color,ptra[_color] rdlong bug_color,ptra[_color] rdlong crickets_x,ptra[_body_x] rdlong crickets_y,ptra[_body_y] rdlong head_x,ptra[_head_x] rdlong head_y,ptra[_head_y] rdlong lfx1,ptra[_left_feeler_x1] rdlong lfy1,ptra[_left_feeler_y1] rdlong lfx2,ptra[_left_feeler_x2] rdlong lfy2,ptra[_left_feeler_y2] rdlong rfx1,ptra[_right_feeler_x1] rdlong rfy1,ptra[_right_feeler_y1] rdlong rfx2,ptra[_right_feeler_x2] rdlong rfy2,ptra[_right_feeler_y2] rdlong crickets_heading,ptra[_heading] ret plot_bug call #get_bug_info plot_bug_2 call #plot_body call #plot_legs call #plot_head call #plot_left_feeler call #plot_right_feeler ret '========================================================== plot_legs mov sa,##700 mov sa2,##250 call #plot_leg2 mov sa,##2900 mov sa2,##-250 call #plot_leg2 ret plot_leg2 mov leg_count,#4 plot_leg3 mov hd2,crickets_heading sub hd2,sa cmps hd2,#0 wcz if_b add hd2,_3600 cmps hd2,_3599 wcz if_a sub hd2,_3600 qfrac hd2,_3600 getqx hd2 qrotate ##body_radius*sx,hd2 getqx x1 getqy y1 add x1,crickets_x add y1,crickets_y qrotate ##(body_radius+leg_length)*sx,hd2 getqx x2 getqy y2 add x2,crickets_x add y2,crickets_y sar x1,#scale sar y1,#scale sar x2,#scale sar y2,#scale call #plot_line add sa,sa2 djnz leg_count,#plot_leg3 ret '========================================================== plot_left_feeler mov x1,lfx1 mov y1,lfy1 mov x2,lfx2 mov y2,lfy2 jmp #plot_feeler plot_right_feeler mov x1,rfx1 mov y1,rfy1 mov x2,rfx2 mov y2,rfy2 plot_feeler sar x1,#scale sar y1,#scale sar x2,#scale sar y2,#scale call #plot_line ret '************************************************************ plot_head mov count2,#head_points mov lut_index,#body_points*2 .ph_loop rdlut x1,lut_index add lut_index,#1 rdlut y1,lut_index add lut_index,#1 add x1,head_x add y1,head_y sar x1,#scale sar y1,#scale call #plot _ret_ djnz count2,#.ph_loop '========================================================== plot_body mov count2,#body_points mov lut_index,#0 .pb_loop rdlut x1,lut_index add lut_index,#1 rdlut y1,lut_index add lut_index,#1 add x1,crickets_x add y1,crickets_y sar x1,#scale sar y1,#scale call #plot _ret_ djnz count2,#.pb_loop '========================================================== calc_bug qfrac crickets_heading,_3600 getqx hd2 qrotate ##(body_radius+head_radius)*sx,hd2 getqx head_x getqy head_y add head_x,crickets_x add head_y,crickets_y mov hd2,crickets_heading sub hd2,##feeler_angle * 10 wc if_c add hd2,_3600 qfrac hd2,_3600 getqx hd2 qrotate ##head_radius*sx,hd2 getqx lfx1 getqy lfy1 add lfx1,head_x add lfy1,head_y qrotate ##feeler_length*sx,hd2 getqx lfx2 getqy lfy2 add lfx2,head_x add lfy2,head_y mov hd2,crickets_heading add hd2,##feeler_angle * 10 cmps hd2,_3599 wcz if_a sub hd2,_3600 qfrac hd2,_3600 getqx hd2 qrotate ##head_radius*sx,hd2 getqx rfx1 getqy rfy1 add rfx1,head_x add rfy1,head_y qrotate ##feeler_length*sx,hd2 getqx rfx2 getqy rfy2 add rfx2,head_x add rfy2,head_y save_bug wrlong head_x,ptra[_head_x] wrlong head_y,ptra[_head_y] wrlong lfx1,ptra[_left_feeler_x1] wrlong lfy1,ptra[_left_feeler_y1] wrlong lfx2,ptra[_left_feeler_x2] wrlong lfy2,ptra[_left_feeler_y2] wrlong rfx1,ptra[_right_feeler_x1] wrlong rfy1,ptra[_right_feeler_y1] wrlong rfx2,ptra[_right_feeler_x2] wrlong rfy2,ptra[_right_feeler_y2] ret init_crickets qfrac #1,_3600 getqx _1deg qfrac ##feeler_angle*10,_3600 getqx fa2 mov color,#1 'bug #0 = red qdiv _3600,#crickets getqx spacing qfrac spacing,_3600 getqx spc2 mov pb,#0 mov count,#crickets loc ptra,#@crickets_data .ib_loop qrotate ##init_radius * sx,pb getqx crickets_x getqy crickets_y add crickets_x,##h_size/2 * sx add crickets_y,##v_size/2 * sx wrlong color,ptra[_color] wrlong crickets_x,ptra[_body_x] wrlong crickets_y,ptra[_body_y] wrlong crickets_heading,ptra[_heading] call #calc_bug add crickets_heading,spacing cmp crickets_heading,_3599 wcz if_a sub crickets_heading,_3600 add pb,spc2 add ptra,#4 * _entries incmod color,#15 wz if_z add color,#1 djnz count,#.ib_loop ret '========================================================== calc_circle qdiv _3600,points mov pa,#0 getqx pb qfrac pb,_3600 getqx pb .cc_loop qrotate radius,pa add pa,pb getqx temp_x wrlut temp_x,lut_index add lut_index,#1 getqy temp_y wrlut temp_y,lut_index add lut_index,#1 _ret_ djnz points,#.cc_loop plot_border mov color,#7 mov x1,#0 mov y1,#0 mov x2,##h_size mov y2,#0 call #plot_line mov x1,#0 mov y1,##v_size-1 mov x2,##h_size mov y2,##v_size-1 call #plot_line mov x1,#0 mov y1,#0 mov x2,#0 mov y2,##v_size-1 call #plot_line mov x1,##h_size-1 mov y1,#0 mov x2,##h_size-1 mov y2,##v_size-1 call #plot_line ret show_crickets mov xcount,#crickets-1 .sb_loop mov selected_bug,xcount call #plot_bug djnf xcount,#.sb_loop ret bug_address mov tmp,selected_bug loc ptra,#@crickets_data mul selected_bug,#4 *_entries add ptra,selected_bug mov selected_bug,tmp ret 'plot line from x1,y1 to x2,y2 in current color plot_lineh2 mov ptra,#4 wrlong x1,ptra++ wrlong y1,ptra++ wrlong x2,ptra++ wrlong y2,ptra++ mov x1,x3 mov y1,y3 mov x2,x4 mov y2,y4 call #plot_lineh mov ptra,#4 rdlong x1,ptra++ rdlong y1,ptra++ rdlong x2,ptra++ rdlong y2,ptra++ ret plot_lineh mov x5,x1 mov y5,y1 mov x1,x2 mov y1,y2 call #ploth 'set_pixel mov x1,x5 mov y1,y5 mov x_inc,#1 mov y_inc,#1 mov width,x2 subs width,x1 abs width wc 'get width negc x_inc mov height,y2 subs height,y1 abs height wc 'get height negc y_inc cmp width,height wcz if_b jmp #.pl2 'x > y and width,##$1ff wz if_z mov width,#1 shl height,#10 '*1024 mov temp2,#0 qdiv height,width getqx temp .pl1 call #ploth 'set_pixel add x1,x_inc add temp2,temp cmp temp2,_1023 wcz if_a add y1,y_inc if_a sub temp2,_1024 djnz width,#.pl1 mov x1,x5 mov y1,y5 ret 'y > x .pl2 and height,##$1ff wz if_z mov height,#1 shl width,#10 '*1924 mov temp2,#0 qdiv width,height getqx temp .pl2a call #ploth 'set_pixel add y1,y_inc add temp2,temp cmp temp2,_1023 wcz if_a add x1,x_inc if_a sub temp2,_1024 djnz height,#.pl2a mov x1,x5 mov y1,y5 ret ploth cmps x1,##h_size-1 wcz if_a ret cmps y1,##v_size-1 wcz if_a ret cmps x1,#0 wcz if_b ret cmps y1,#0 wcz if_b ret mov y9,y1 mul y1,#h_size/2 mov x9,x1 mov ptrb,current_buffer testb x1,#0 wc shr x1,#1 add ptrb,x1 add ptrb,y1 rdbyte tempr,ptrb mov x1,x9 mov y1,y9 if_nc setnib tempr,color,#0 if_c setnib tempr,color,#1 wrbyte tempr,ptrb ret '777777777777777777777777777777777777777777777777777777777777777777777777777777777 orgh org comms wrpin #%11111_0,#rx_pin wxpin ##nco | 7,#rx_pin dirh #rx_pin wrpin #%1_11110_0,#tx_pin wxpin ##nco | 7,#tx_pin dirh #tx_pin qfrac #15,#360 getqx _15deg comms_main testp #rx_pin wc if_nc jmp #no_key rdpin char,#rx_pin getbyte key,char,#3 loc ptra,#@crickets_data mov char,bug_to_view mul char,#_entries * 4 add ptra,char cmp key,#"+" wcz if_e incmod bug_to_view,#crickets-1 cmp key,#"-" wcz if_e decmod bug_to_view,#crickets-1 cmp key,#"c" wcz if_e wrlong #0,#overrides cmp key,#"l" wcz if_e rdlong char,ptra[_heading] if_e add char,_15deg if_e call #heading_check if_e wrlong char,ptra[_heading] cmp key,#"p" wcz if_ne jmp #no_key decod char2,bug_to_view rdlong char,#overrides xor char,char2 wrlong char,#overrides no_key mov char,#1 call #send_char 'loc ptrb,#@labels math_stuff mov r3,#_entries+2 'mov ptra,#$20 loc ptra,#@crickets_data mov r0,bug_to_view mul r0,#_entries * 4 add ptra,r0 loc ptrb,#@bug_msg call #print mov r0,bug_to_view call #show_dec .loopm call #print rdlong r0,ptra++ call #hex8 call #show_dec djnz r3,#.loopm mov char,#13 call #send_char waitx ##sys_clk / 2 jmp #comms_main mov r2,#3 mul r2,#4 * _entries loc ptra,#@crickets_data add ptra,r2 loc ptrb,#@labels mov r3,#_entries .loop call #print rdlong r0,ptra++ call #hex8 djnz r3,#.loop waitx ##sys_clk / 5 jmp #comms_main heading_check cmp char,##3599 wcz if_a sub char,##3600 cmps char,#0 wcz if_b add char,##3600 ret wcz hex8 mov r1,#8 .loop getnib char,r0,#7 cmp char,#9 wcz if_a add char,#"A"-10 if_be add char,#"0" call #send_char rol r0,#4 djnz r1,#.loop mov char,#32 '13 send_char rdpin status,#tx_pin wc if_c jmp #send_char wypin char,#tx_pin ret wc print rdbyte char,ptrb++ wz if_z ret call #send_char jmp #print show_dec mov r7,#32 mov r6,#0 mov r5,#0 testb r0,#31 wc wrc sign if_c neg r0 .loop getnib char,r5,#1 cmp char,#4 wcz if_a add char,#3 setnib r5,char,#1 getnib char,r5,#0 cmp char,#4 wcz if_a add char,#3 setnib r5,char,#0 rep @.loop2,#8 getnib char,r6,#0 cmp char,#4 wcz if_a add char,#3 setnib r6,char,#0 ror r6,#4 .loop2 rcl r0,#1 wc rcl r6,#1 wc rcl r5,#1 djnz r7,#.loop mov char,#" " testb sign,#0 wc if_c mov char,#"-" call #send_char mov r0,r5 call #hex2 mov r0,r6 call #hex8 mov char,#13 call #send_char ret hex2 getnib char,r0,#1 cmp char,#9 wcz if_a add char,#"A"-10 if_be add char,#"0" call #send_char getnib char,r0,#0 cmp char,#9 wcz if_a add char,#"A"-10 if_be add char,#"0" call #send_char ret _15deg long 0 key long 0 bug_to_view long 0 sign res 1 r0 res 1 r1 res 1 r2 res 1 r3 res 1 r4 res 1 r5 res 1 r6 res 1 r7 res 1 char res 1 char2 res 1 status res 1 '3333333333333333333333333333333333333333333333333333333333333333333333333333333 org plot2_boot long 0 setluts #1 'lut can be written to by cog #2 call #init_constants .loop waitatn rdlong mode,#mode_address testb mode,#mode_biv wc if_nc jmp #.loop mov idx,#0 rdbyte pa,#0 wz if_z loc ptra,#@video_buffer0 if_nz loc ptra,#@video_buffer1 mov current_buffer,ptra .loop2 rdlut v_angle,idx cmp v_angle,##-1 wcz if_e jmp #.loop add idx,#1 rdlut x1,idx add idx,#1 rdlut y1,idx add idx,#1 qrotate ##react_range * sx,v_angle mov color,#2 getqx x2 getqy y2 add x2,x1 add y2,y1 sar x1,#scale sar y1,#scale sar x2,#scale sar y2,#scale call #plot_line2 jmp #.loop2 idx long 0 v_angle long 0 'plot line from x1,y1 to x2,y2 in current color plot_line2 mov x5,x1 mov y5,y1 mov x1,x2 mov y1,y2 call #plot2 'set_pixel mov y1,y5 mov x1,x5 mov x_inc,#1 mov y_inc,#1 mov width,x2 subs width,x1 abs width wc 'get width negc x_inc mov height,y2 subs height,y1 abs height wc 'get height negc y_inc cmp width,height wcz if_b jmp #.pl2 'x > y and width,##$ffff wz if_z mov width,#1 shl height,#10 '*1024 mov temp2,#0 qdiv height,width getqx temp .pl1 call #plot2 'set_pixel add x1,x_inc add temp2,temp cmp temp2,_1023 wcz if_a add y1,y_inc if_a sub temp2,_1024 djnz width,#.pl1 ret 'y > x .pl2 and height,##$ffff wz if_z mov height,#1 shl width,#10 '*1024 mov temp2,#0 qdiv width,height getqx temp .pl2a call #plot2 'set_pixel add y1,y_inc add temp2,temp cmp temp2,_1023 wcz if_a add x1,x_inc if_a sub temp2,_1024 djnz height,#.pl2a ret plot2 cmps x1,##h_size-1 wcz if_a ret cmps y1,##v_size-1 wcz if_a ret testb x1,#31 wc testb y1,#31 orc if_c ret mov y9,y1 qmul y1,#h_size/2 mov x9,x1 mov ptrb,current_buffer testb x1,#0 wc shr x1,#1 add ptrb,x1 add ptrb,y1 rdbyte tempr,ptrb mov x1,x9 mov y1,y9 if_nc setnib tempr,color,#0 if_c setnib tempr,color,#1 wrbyte tempr,ptrb ret '5555555555555555555555555555555555555555555555555555555555555555555555 org plot3_boot long 0 call #init_constants .loop waitatn rdlong mode,#mode_address rdbyte pa,#0 wz if_z loc ptra,#@video_buffer0 if_nz loc ptra,#@video_buffer1 mov current_buffer,ptra rdlong mode,#mode_address mov bug1,#0 .lp2 mov bug2,bug1 add bug2,#1 .lp1 loc ptra,#@crickets_data mov pa,bug1 mul pa,#4*_entries add ptra,pa mov ptra1,ptra rdlong heading1,ptra[_heading] rdlong x1,ptra[_head_x] rdlong y1,ptra[_head_y] qfrac heading1,_3600 getqx pa qrotate ##rr,pa '##react_range*sx,pa getqx x2 add x2,x1 sar x1,#scale sar x2,#scale getqy y2 add y2,y1 sar y1,#scale sar y2,#scale mov color,#7 loc ptra,#@crickets_data mov pa,bug2 mul pa,#4*_entries add ptra,pa mov ptra2,ptra rdlong heading2,ptra[_heading] rdlong x3,ptra[_head_x] rdlong y3,ptra[_head_y] qfrac heading2,_3600 getqx pa qrotate ##rr,pa '##react_range*sx,pa getqx x4 add x4,x3 sar x3,#scale sar x4,#scale getqy y4 add y4,y3 sar y3,#scale sar y4,#scale mov color,#7 mov k0,x1 sub k0,x2 mov k1,y1 sub k1,y2 qvector k0,k1 getqx k0 'length cmp k0,##rr wcz '##react_range * sx wcz if_be call #math incmod bug2,#crickets-1 wz if_nz jmp #.lp1 incmod bug1,#crickets-2 wz if_nz jmp #.lp2 'show vapor trails testb mode,#mode_trails wc if_nc jmp #.loop loc pb,#@crickets_data loc ptra,#@trails mov bz,#crickets .loop77 rdlong color,pb mov trc,##trail_length .loop6 rdlong y1,ptra++ getword x1,y1,#1 getword y1,y1,#0 call #ploth djnz trc,#.loop6 add pb,##_entries*4 djnz bz,#.loop77 jmp #.loop trc long 0 bz long 0 'line intersection test ' d = ((y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1)) math altr 0,#_y4y3 sub y4,y3 'y4 - y3 altr 0,#_x2x1 sub x2,x1 'x2 - x1 qmul _y4y3,_x2x1 altr 0,#_x4x3 sub x4,x3 'x4 - x3 altr 0,#_y2y1 sub y2,y1 'y2 - y1 getqx d0 qmul _x4x3,_y2y1 getqx d1 subs d0,d1 abs d0 wc wrc d_sign 'save sign ' ua = ((x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3)) / d altr 0,#_y1y3 sub y1,y3 'y1 - y3 qmul _x4x3,_y1y3 altr 0,#_x1x3 sub x1,x3 'x1 - x3 qmul _y4y3,_x1x3 getqx ua0 getqx ua1 sub ua0,ua1 qmul ua0,_10_000 getqx ua abs ua wc wrc ua_sign qdiv ua,d0 getqx k0 testb d_sign,#0 xorc negc k0 ' ub = ((x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3)) / d qmul _x2x1,_y1y3 qmul _y2y1,_x1x3 getqx ub0 getqx ub1 sub ub0,ub1 qmul ub0,_10_000 getqx ub abs ub wc wrc ub_sign qdiv ub,d0 getqx k1 testb d_sign,#0 xorc negc k1 'if ua > 0 and ua < 1000 and ub > 0 and ub < 1000 'intersects cmps k0,#1 wcz if_b jmp #not_intersect cmps k1,#1 wcz if_b jmp #not_intersect cmps k0,_9999 wcz if_a ret cmps k1,_9999 wcz if_a ret ' lx = x1 + ua * (x2 - x1) ' ly = y1 + ua * (y2 - y1) qmul _x2x1,k0 qmul _y2y1,k0 getqx k0 abs k0 wc wrc k0_sign 'save sign getqx k1 abs k1 wc wrc k1_sign 'save sign qdiv k0,_10_000 qdiv k1,_10_000 getqx k0 testb k0_sign,#0 wc negc k0 getqx k1 testb k1_sign,#0 wc negc k1 altr 0,#lx add x1,k0 altr 0,#ly add y1,k1 'turn away, swap headings to avoid collision mov ptra,ptra1 wrlong heading2,ptra[_heading] mov ptra,ptra2 wrlong heading1,ptra[_heading] not_intersect ret uaq long 0 ubq long 0 ua_sign long 0 ub_sign long 0 _9999 long 9999 _10_000 long 10_000 start res 1 finish res 1 intersect res 1 k0_sign res 1 k1_sign res 1 lx res 1 ly res 1 ua res 1 ub res 1 x3 res 1 x4 res 1 y3 res 1 y4 res 1 d0 res 1 d1 res 1 _y4y3 res 1 _y2y1 res 1 _x4x3 res 1 _x2x1 res 1 _y1y2 res 1 _x1x2 res 1 _y1y3 res 1 _x1x3 res 1 ua0 res 1 ua1 res 1 ub0 res 1 ub1 res 1 k0 res 1 k1 res 1 d_sign res 1 bug1 res 1 bug2 res 1 heading1 res 1 heading2 res 1 ptra1 res 1 ptra2 res 1 '66666666666666666666666666666666666666666666666666666666666666666666666666666666 orgh org vector_text long 0 hold call #init_constants mov hold,#1 vector_main waitatn cmp hold,##1500 wcz if_e jmp #vector_main add hold,#1 mov font_scale,#2 loc ptra,#@title mov cursor_x,#0 mov cursor_y,#0 mov color,#7 call #plot_text loc ptra,#@title2 mov cursor_x,#0 mov cursor_y,#440 mov color,#2 call #plot_text mov font_scale,#4 loc ptra,#@title3 mov cursor_x,#0 mov cursor_y,#200 mov color,#4 call #plot_text jmp #vector_main vtext mov move,#0 mov move2,#0 mov moves,#0 mov moves2,#0 rdbyte pa,#0 wz if_z loc ptra,#@video_buffer0 if_nz loc ptra,#@video_buffer1 mov current_buffer,ptra shl ascii,#1 loc ptra,#@primary_table add ptra,ascii rdword address,ptra mov moves,address shr moves,#11 and address,##$7ff mov subchain_mode,#0 '****** text_loop loc ptrb,#@vector_table testb subchain_mode,#0 wc if_nc add ptrb,address if_nc add address,#1 if_nc add move,#1 if_c add ptrb,address2 if_c add address2,#1 if_c add move2,#1 rdbyte val,ptrb ' 'init subchain ' testb subchain_mode,#0 wc if_c jmp #check2 cmp val,#0 wcz if_ne jmp #check2 bith subchain_mode,#0 mov move2,#0 loc ptrb,#@vector_table add ptrb,address rdbyte val,ptrb sub val,#1 shl val,#1 loc ptrb,#@subchain_table add ptrb,val rdword address2,ptrb mov moves2,address2 shr moves2,#11 and address2,##$7ff add address,#1 add move,#1 jmp #exit_check ' '1/2 shift right ' check2 cmp val,#2 wcz if_e mov shift,#1 if_e jmp #exit_check ' 'move pen ' mov last_vert,current_vert mov last_horiz,current_horiz mov vert,val shr vert,#4 subr vert,#15 mov horiz,val and horiz,#$e add horiz,shift mov shift,#0 mov pa,font_scale shr pa,#1 mov current_horiz,horiz mul current_horiz,pa mov current_vert,vert mul current_vert,font_scale add current_horiz,cursor_x '#320 add current_vert,cursor_y '#140 testb val,#0 wc if_c jmp #exit_check 'pen down so plot line mov x1,last_horiz mov y1,last_vert mov x2,current_horiz mov y2,current_vert call #vplot_line exit_check testb subchain_mode,#0 wc if_nc jmp #text3 cmp move2,moves2 wcz if_ae mov subchain_mode,#0 if_ae mov move2,#0 text3 cmp move,moves wcz if_be jmp #text_loop ret last_vert long 0 last_horiz long 0 current_vert long 0 current_horiz long 0 val long 0 vert long 0 horiz long 0 pen long 0 address long 0 address2 long 0 moves long 0 moves2 long 0 move long 0 move2 long 0 ascii long 0 subchain_mode long 0 shift long 0 font_scale long 2 msg_ptr long 0 plot_text mov msg_ptr,ptra .loop rdbyte ascii,msg_ptr wz add msg_ptr,#1 if_z ret cmp ascii,#32 wz if_e jmp #.ignore mov pa,#16 mul pa,font_scale cmp ascii,#13 wcz if_e mov cursor_x,#0 if_e add cursor_y,pa if_e jmp #.loop call #vtext .ignore mov ascii,#9 mul ascii,font_scale add cursor_x,ascii jmp #.loop cursor_x long 0 cursor_y long 0 '************************************************************ vplot cmps x1,##h_size-1 wcz if_a ret cmps y1,##v_size-1 wcz if_a ret testb x1,#31 wc testb y1,#31 orc if_c ret mov x9,x1 mov y9,y1 mul y1,#320 mov ptrb,current_buffer testb x1,#0 wc shr x1,#1 add ptrb,x1 add ptrb,y1 rdbyte tempr,ptrb mov x1,x9 mov y1,y9 if_nc setnib tempr,color,#0 if_c setnib tempr,color,#1 wrbyte tempr,ptrb ret 'plot line from x1,y1 to x2,y2 in current color vplot_line mov x5,x1 mov y5,y1 mov x1,x2 mov y1,y2 call #vplot 'set_pixel mov y1,y5 mov x1,x5 mov x_inc,#1 mov y_inc,#1 mov width,x2 subs width,x1 abs width wc 'get width negc x_inc mov height,y2 subs height,y1 abs height wc 'get height negc y_inc cmp width,height wcz if_b jmp #.pl2 'x > y and width,##$ffff wz if_z mov width,#1 shl height,#10 '*1924 mov temp2,#0 qdiv height,width getqx temp .pl1 call #vplot 'set_pixel add x1,x_inc add temp2,temp cmp temp2,_1023 wcz if_a add y1,y_inc if_a sub temp2,_1024 djnz width,#.pl1 ret 'y > x .pl2 and height,##$ffff wz if_z mov height,#1 shl width,#10 '*1024 mov temp2,#0 qdiv width,height getqx temp .pl2a call #vplot 'set_pixel add y1,y_inc add temp2,temp cmp temp2,_1023 wcz if_a add x1,x_inc if_a sub temp2,_1024 djnz height,#.pl2a ret orgh title byte "PARALLAX PROPELLER 2",13 byte "P2X8C4M64P_ES",13 byte "Cordic Crickets Demo",13 byte "Ver 2.20 ",13 byte "By ozpropdev 26th Dec 2018",13 byte 0 title2 byte "Autonomous navigation simulation" byte 0 title3 byte " PARALLAX",13 byte " PROPELLER 2",13 byte 0 '-------------------------------------------------------------------------------- orgh bug_msg byte "Bug number ",0 labels byte "color ",0 byte "body_x ",0 byte "body_y ",0 byte "heading ",0 byte "head_x ",0 byte "head_y ",0 byte "left_feeler_x1 ",0 byte "left_feeler_y1 ",0 byte "left_feeler_x2 ",0 byte "left_feeler_y2 ",0 byte "right_feeler_x1 ",0 byte "right_feeler_y1 ",0 byte "right_feeler_x2 ",0 byte "right_feeler_y2 ",0 byte "closest_bug ",0 msg2 byte "d= ",0 byte "ua= ",0 byte "ua*10000= ",0 byte "ua/d= ",0 byte "ub= ",0 byte "ub*10000= ",0 byte "ub/d= ",0 byte "intersects ",0 byte "x2x1= ",0 byte "y2y1= ",0 byte "x offset ",0 byte "y offset ",0 byte "lx = ",0 byte "ly = ",0 byte "cycles = ",0 byte "elapsed = ",0 byte " ",0 byte " ",0 byte " ",0 vector_table byte $B1,$F0,$B6,$F6,$B5,$74,$7A,$BA,$79,$38,$3E '#0 byte $F7,$F0,$D0,$D6,$B6,$B0,$B5,$74,$7A,$BA,$B4,$79,$38,$59,$5E,$7F,$3E '#1 byte $0,$4,$B5,$BA,$2,$B7,$2,$76,$79,$3E,$39,$7E '#2 byte $D1,$D4,$F7,$F0,$B0,$B6,$0,$5 '#3 byte $0,$6,$0,$7,$79,$7E,$2,$7A,$2,$3A '#4 byte $0,$6,$75,$B4,$7A,$BA,$4D,$3E,$38,$78,$7E,$3E '#5 byte $B1,$F0,$F6,$B6,$D1,$D6,$0,$8,$79,$38,$49,$7E,$5B,$3E '#6 byte $F7,$E6,$D4,$C6,$B6,$0,$6,$0,$9 '#7 byte $0,$A,$0,$6,$BB,$B4,$94,$9A,$7A,$74 '#8 byte $B1,$F0,$D1,$D6,$F7,$B6,$0,$B '#9 byte $F1,$B0,$B6,$BB,$B4,$74,$95,$98 '#10 byte $F1,$2,$B2,$F6,$0,$B '#11 byte $F7,$F0,$B0,$D1,$D4,$0,$C '#12 byte $F7,$F0,$B0,$B6,$75,$B4,$BA,$9A,$94,$99,$7A '#13 byte $0,$D '#14 byte $0,$4,$B9,$78 '#15 byte $0,$E,$B5,$74,$7A,$7F,$78,$38,$3E,$59,$5C '#16 byte $0,$F,$6B,$7C,$3C,$3B,$3E '#17 byte $0,$F,$69,$7A,$7E,$5E,$48,$38,$3E '#18 byte $0,$F,$79,$7E,$3E,$38,$5B,$5E '#19 byte $0,$F,$4F,$48,$7C,$3C '#20 byte $0,$10,$75,$B4,$BA,$7A,$95,$9A,$0,$11 '#21 byte $0,$4,$B5,$94,$9A,$BA,$2,$97,$2,$76,$39,$78,$3E,$7E '#22 byte $0,$6,$0,$B,$7F,$78,$38,$3E,$4E,$5C,$58,$5D,$6E,$7E '#23 byte $0,$12,$0,$13,$0,$14 '#24 byte $0,$6,$75,$B4,$2,$96,$BA,$7A '#25 byte $0,$4,$0,$15,$0,$16 '#26 byte $0,$6,$BB,$B4,$94,$9A,$7A,$74,$0,$17 '#27 byte $0,$18,$0,$19 '#28 byte $0,$12,$D6,$D4,$0,$19 '#29 byte $B1,$F0,$F6,$D6,$D0,$D5,$B6,$0,$19 '#30 byte $F1,$B0,$B6,$F6,$0,$19 '#31 byte $5F '#32 " " byte $59,$68,$66,$56,$58,$2,$77,$F8,$F6,$2,$76 '#33 "!" byte $C5,$E6,$F6,$F4,$E4,$E6,$C9,$EA,$FA,$F8,$E8,$EA '#34 """ byte $91,$9E,$BF,$B0,$F7,$54,$59,$FA '#35 "#" byte $F7,$54,$59,$FA,$ED,$E4,$D2,$B2,$A4,$AA,$9C,$7C,$6A,$62 '#36 "$" byte $F5,$D0,$F0,$FE,$50,$5F,$5A,$7E,$5E '#37 "%" byte $AD,$58,$54,$70,$90,$D6,$E6,$F4,$F2,$E0,$D0,$5E '#38 "&" byte $C7,$E8,$F8,$F6,$E6,$E8 '#39 "'" byte $F9,$E6,$B4,$94,$66,$58 '#40 "(" byte $F7,$E8,$BA,$9A,$68,$56 '#41 ")" byte $63,$EC,$E3,$6C,$A1,$AE '#42 "*" byte $A1,$AE,$2,$E7,$2,$66 '#43 "+" byte $37,$58,$59,$68,$66,$56,$58 '#44 "," byte $A1,$AE '#45 "-" byte $59,$68,$66,$56,$58 '#46 "." byte $55,$FA '#47 "/" byte $55,$62,$80,$C0,$E2,$F4,$FA,$EC,$CE,$8E,$6C,$5A,$54 '#48 "0" byte $D5,$F8,$58,$55,$5C '#49 "1" byte $D1,$F4,$FA,$DE,$BE,$AC,$82,$50,$5E '#50 "2" byte $F3,$FE,$CC,$BA,$B6,$BB,$9E,$7E,$5A,$54,$70 '#51 "3" byte $5B,$FA,$70,$7E '#52 "4" byte $71,$54,$5A,$7E,$AE,$CA,$C0,$F0,$FC '#53 "5" byte $91,$B4,$BA,$9E,$7E,$5A,$54,$70,$90,$D4,$FA '#54 "6" byte $D1,$F0,$FE,$88,$58 '#55 "7" byte $BB,$CC,$EC,$FA,$F4,$E2,$C2,$B4,$91,$B4,$BA,$9E,$7E,$5A,$54,$70,$90 '#56 "8" byte $BF,$9A,$94,$B0,$D0,$F4,$FA,$DE,$BE,$7A,$54 '#57 "9" byte $C9,$D8,$D6,$C6,$C8,$79,$88,$86,$76,$78 '#58 ":" byte $79,$88,$86,$76,$78,$37,$58,$59,$68,$66,$56,$58 '#59 ";" byte $DF,$A0,$7E '#60 "<" byte $C1,$CE,$81,$8E '#61 "=" byte $71,$AE,$D0 '#62 ">" byte $E1,$F4,$FA,$DE,$AC,$96,$86,$67,$64,$54,$56,$66 '#63 "?" byte $BB,$C8,$C6,$B4,$94,$86,$88,$9A,$CB,$8A,$7C,$8E,$DE,$FA,$F4,$D0,$70,$54,$5A '#64 "@" byte $51,$D0,$F4,$FA,$DE,$5E,$91,$9E '#65 "A" byte $51,$F0,$FA,$EC,$CC,$BA,$B0,$BB,$9E,$7E,$5A,$50 '#66 "B" byte $DF,$FA,$F4,$D0,$70,$54,$5A,$7E '#67 "C" byte $51,$F0,$FA,$DE,$7E,$5A,$50 '#68 "D" byte $A1,$A8,$FF,$F0,$50,$5E '#69 "E" byte $A1,$A8,$FF,$F0,$50 '#70 "F" byte $A9,$AE,$5E,$DF,$FA,$F4,$D0,$70,$54,$5A,$7E '#71 "G" byte $51,$F0,$A1,$AE,$FF,$5E '#72 "H" byte $F5,$FA,$2,$F7,$2,$56,$55,$5A '#73 "I" byte $91,$70,$54,$5A,$7E,$FE '#74 "J" byte $51,$F0,$FF,$80,$A5,$5E '#75 "K" byte $F1,$50,$5E '#76 "L" byte $51,$F0,$2,$56,$FE,$5E '#77 "M" byte $51,$F0,$5E,$FE '#78 "N" byte $DF,$FA,$F4,$D0,$70,$54,$5A,$7E,$DE '#79 "O" byte $51,$F0,$FA,$DE,$BE,$9A,$90 '#80 "P" byte $DF,$FA,$F4,$D0,$70,$54,$5A,$7E,$DE,$77,$3E '#81 "Q" byte $51,$F0,$FA,$DE,$BE,$9A,$90,$99,$5E '#82 "R" byte $71,$54,$5A,$7E,$8E,$AA,$A4,$C0,$D0,$F4,$FA,$DE '#83 "S" byte $F1,$FE,$2,$F7,$2,$56 '#84 "T" byte $F1,$70,$54,$5A,$7E,$FE '#85 "U" byte $F1,$2,$56,$FE '#86 "V" byte $F1,$52,$2,$A6,$5C,$FE '#87 "W" byte $51,$FE,$F1,$5E '#88 "X" byte $F1,$2,$96,$FE,$2,$97,$2,$56 '#89 "Y" byte $8B,$C4,$F1,$FE,$50,$5E '#90 "Z" byte $FB,$F6,$56,$5A '#91 "[" byte $F5,$5A '#92 "\" byte $F5,$F8,$58,$54 '#93 "]" byte $A1,$C4,$9E '#94 "^" byte $41,$4E '#95 "_" byte $D3,$8C '#96 "`" byte $BD,$5C,$6D,$5A,$54,$62,$A2,$B4,$BA,$AC '#97 "a" byte $F3,$52,$63,$54,$5A,$6C,$AC,$BA,$B4,$A2 '#98 "b" byte $6D,$5A,$54,$62,$A2,$B4,$BA,$AC '#99 "c" byte $ED,$5C,$0,$1 '#100 "d" byte $6D,$5A,$54,$62,$A2,$B4,$BA,$AC,$8C,$82 '#101 "e" byte $EB,$FA,$F4,$54,$57,$52,$A3,$A8 '#102 "f" byte $0,$1,$BD,$2C,$1A,$14,$22 '#103 "g" byte $F3,$52,$A3,$B4,$BA,$AC,$5C '#104 "h" byte $55,$58,$D9,$E8,$E6,$D6,$D8,$B9,$B6,$56 '#105 "i" byte $D9,$E8,$E6,$D6,$D8,$B9,$B6,$56,$16,$32 '#106 "j" byte $F3,$52,$63,$BC,$87,$5C '#107 "k" byte $F9,$F6,$56,$55,$58 '#108 "l" byte $51,$B0,$A1,$B2,$B4,$A6,$56,$A7,$B8,$BA,$AC,$5C '#109 "m" byte $53,$B2,$0,$3 '#110 "n" byte $63,$54,$5A,$6C,$AC,$BA,$B4,$A2,$62 '#111 "o" byte $B3,$12,$0,$2 '#112 "p" byte $0,$1,$BD,$1C '#113 "q" byte $B3,$B4,$54,$85,$BA,$9C '#114 "r" byte $63,$54,$5A,$6C,$7C,$8A,$84,$92,$A2,$B4,$BA,$AC '#115 "s" byte $B3,$BA,$D9,$E6,$56,$5A '#116 "t" byte $B3,$62,$54,$5A,$6C,$BD,$5C '#117 "u" byte $B3,$2,$56,$BC '#118 "v" byte $B1,$52,$86,$5A,$BC '#119 "w" byte $53,$BC,$B3,$5C '#120 "x" byte $B3,$54,$5A,$15,$18,$5A,$BC '#121 "y" byte $85,$8A,$B3,$BC,$52,$5C '#122 "z" byte $FB,$F6,$B8,$A6,$98,$56,$5A '#123 "{" byte $F9,$58 '#124 "|" byte $F5,$F8,$B6,$A8,$96,$58,$54 '#125 "}" byte $91,$B4,$9A,$BE '#126 "~" byte $B1,$F0,$F4,$E6,$C6,$B4,$B0,$BB,$B4,$74,$7A,$95,$98,$79,$38,$3E '#127 "" subchains byte $6D,$5A,$54,$62,$A2,$B4,$BA,$AC '#1 byte $63,$54,$5A,$6C,$AC,$BA,$B4,$A2 '#2 byte $52,$A3,$B4,$BA,$AC,$5C '#3 byte $F7,$F0,$D0,$D6,$B6,$B0 '#4 byte $B5,$BA,$2,$B7,$2,$76,$79,$3E,$39,$7E '#5 byte $D1,$D4,$F7,$F0,$B0,$B6 '#6 byte $B5,$74,$7A,$BA,$B4 '#7 byte $BB,$B4,$74,$7A '#8 byte $BB,$B4,$74,$7A,$95,$98,$79,$38,$3E '#9 byte $F7,$E6,$D4,$C6,$B6 '#10 byte $B5,$BA,$2,$B7,$2,$76 '#11 byte $BB,$B4,$74,$95,$98 '#12 byte $F7,$F0,$D0,$D6,$B6,$B0,$B5,$74,$7A,$BA,$B4 '#13 byte $B1,$F0,$F4,$E6,$C6,$B4,$B0 '#14 byte $B1,$F0,$F4,$E6,$C6,$B4,$B0,$BB,$B4,$74,$7A '#15 byte $B1,$F0,$B6,$F6 '#16 byte $79,$38,$49,$7E,$5B,$3E '#17 byte $F7,$F0,$B0,$B6 '#18 byte $75,$B4,$BA,$7A,$95,$9A '#19 byte $39,$78,$3E,$7E '#20 byte $B5,$74,$7A,$BA '#21 byte $7F,$78,$38,$3E,$4E,$5C,$58,$5D,$6E,$7E '#22 byte $7F,$78,$38,$3E '#23 byte $D1,$D4,$F7,$F0,$B0 '#24 byte $BB,$B4,$94,$9A,$7A,$74 '#25 byte '#26 primary_table word 11 << 11 | 0 '#0 word 17 << 11 | 11 '#1 word 12 << 11 | 28 '#2 word 8 << 11 | 40 '#3 word 10 << 11 | 48 '#4 word 12 << 11 | 58 '#5 word 14 << 11 | 70 '#6 word 9 << 11 | 84 '#7 word 10 << 11 | 93 '#8 word 8 << 11 | 103 '#9 word 8 << 11 | 111 '#10 word 6 << 11 | 119 '#11 word 7 << 11 | 125 '#12 word 11 << 11 | 132 '#13 word 2 << 11 | 143 '#14 word 4 << 11 | 145 '#15 word 11 << 11 | 149 '#16 word 7 << 11 | 160 '#17 word 9 << 11 | 167 '#18 word 8 << 11 | 176 '#19 word 6 << 11 | 184 '#20 word 10 << 11 | 190 '#21 word 14 << 11 | 200 '#22 word 14 << 11 | 214 '#23 word 6 << 11 | 228 '#24 word 8 << 11 | 234 '#25 word 6 << 11 | 242 '#26 word 10 << 11 | 248 '#27 word 4 << 11 | 258 '#28 word 6 << 11 | 262 '#29 word 9 << 11 | 268 '#30 word 6 << 11 | 277 '#31 word 1 << 11 | 283 '#32 " " word 11 << 11 | 284 '#33 "!" word 12 << 11 | 295 '#34 """ word 8 << 11 | 307 '#35 "#" word 14 << 11 | 315 '#36 "$" word 9 << 11 | 329 '#37 "%" word 12 << 11 | 338 '#38 "&" word 6 << 11 | 350 '#39 "'" word 6 << 11 | 356 '#40 "(" word 6 << 11 | 362 '#41 ")" word 6 << 11 | 368 '#42 "*" word 6 << 11 | 374 '#43 "+" word 7 << 11 | 380 '#44 "," word 2 << 11 | 387 '#45 "-" word 5 << 11 | 389 '#46 "." word 2 << 11 | 394 '#47 "/" word 13 << 11 | 396 '#48 "0" word 5 << 11 | 409 '#49 "1" word 9 << 11 | 414 '#50 "2" word 11 << 11 | 423 '#51 "3" word 4 << 11 | 434 '#52 "4" word 9 << 11 | 438 '#53 "5" word 11 << 11 | 447 '#54 "6" word 5 << 11 | 458 '#55 "7" word 17 << 11 | 463 '#56 "8" word 11 << 11 | 480 '#57 "9" word 10 << 11 | 491 '#58 ":" word 12 << 11 | 501 '#59 ";" word 3 << 11 | 513 '#60 "<" word 4 << 11 | 516 '#61 "=" word 3 << 11 | 520 '#62 ">" word 12 << 11 | 523 '#63 "?" word 19 << 11 | 535 '#64 "@" word 8 << 11 | 554 '#65 "A" word 12 << 11 | 562 '#66 "B" word 8 << 11 | 574 '#67 "C" word 7 << 11 | 582 '#68 "D" word 6 << 11 | 589 '#69 "E" word 5 << 11 | 595 '#70 "F" word 11 << 11 | 600 '#71 "G" word 6 << 11 | 611 '#72 "H" word 8 << 11 | 617 '#73 "I" word 6 << 11 | 625 '#74 "J" word 6 << 11 | 631 '#75 "K" word 3 << 11 | 637 '#76 "L" word 6 << 11 | 640 '#77 "M" word 4 << 11 | 646 '#78 "N" word 9 << 11 | 650 '#79 "O" word 7 << 11 | 659 '#80 "P" word 11 << 11 | 666 '#81 "Q" word 9 << 11 | 677 '#82 "R" word 12 << 11 | 686 '#83 "S" word 6 << 11 | 698 '#84 "T" word 6 << 11 | 704 '#85 "U" word 4 << 11 | 710 '#86 "V" word 6 << 11 | 714 '#87 "W" word 4 << 11 | 720 '#88 "X" word 8 << 11 | 724 '#89 "Y" word 6 << 11 | 732 '#90 "Z" word 4 << 11 | 738 '#91 "[" word 2 << 11 | 742 '#92 "\" word 4 << 11 | 744 '#93 "]" word 3 << 11 | 748 '#94 "^" word 2 << 11 | 751 '#95 "_" word 2 << 11 | 753 '#96 "`" word 10 << 11 | 755 '#97 "a" word 10 << 11 | 765 '#98 "b" word 8 << 11 | 775 '#99 "c" word 4 << 11 | 783 '#100 "d" word 10 << 11 | 787 '#101 "e" word 8 << 11 | 797 '#102 "f" word 7 << 11 | 805 '#103 "g" word 7 << 11 | 812 '#104 "h" word 10 << 11 | 819 '#105 "i" word 10 << 11 | 829 '#106 "j" word 6 << 11 | 839 '#107 "k" word 5 << 11 | 845 '#108 "l" word 12 << 11 | 850 '#109 "m" word 4 << 11 | 862 '#110 "n" word 9 << 11 | 866 '#111 "o" word 4 << 11 | 875 '#112 "p" word 4 << 11 | 879 '#113 "q" word 6 << 11 | 883 '#114 "r" word 12 << 11 | 889 '#115 "s" word 6 << 11 | 901 '#116 "t" word 7 << 11 | 907 '#117 "u" word 4 << 11 | 914 '#118 "v" word 5 << 11 | 918 '#119 "w" word 4 << 11 | 923 '#120 "x" word 7 << 11 | 927 '#121 "y" word 6 << 11 | 934 '#122 "z" word 7 << 11 | 940 '#123 "{" word 2 << 11 | 947 '#124 "|" word 7 << 11 | 949 '#125 "}" word 4 << 11 | 956 '#126 "~" word 16 << 11 | 960 '#127 "" subchain_table word 8 << 11 | 976 '#1 word 8 << 11 | 984 '#2 word 6 << 11 | 992 '#3 word 6 << 11 | 998 '#4 word 10 << 11 | 1004 '#5 word 6 << 11 | 1014 '#6 word 5 << 11 | 1020 '#7 word 4 << 11 | 1025 '#8 word 9 << 11 | 1029 '#9 word 5 << 11 | 1038 '#10 word 6 << 11 | 1043 '#11 word 5 << 11 | 1049 '#12 word 11 << 11 | 1054 '#13 word 7 << 11 | 1065 '#14 word 11 << 11 | 1072 '#15 word 4 << 11 | 1083 '#16 word 6 << 11 | 1087 '#17 word 4 << 11 | 1093 '#18 word 6 << 11 | 1097 '#19 word 4 << 11 | 1103 '#20 word 4 << 11 | 1107 '#21 word 10 << 11 | 1111 '#22 word 4 << 11 | 1121 '#23 word 5 << 11 | 1125 '#24 word 6 << 11 | 1130 '#25 word 0 << 11 | 1136 '#26 alignl crickets_data long 0[crickets * _entries] trails long 0[crickets * trail_length] alignl video_buffer0 long 0[(h_size / 8) * v_size] video_buffer1 long 0[(h_size / 8) * v_size]