Module: ShapeTable

Included in:
ShapeTableFont
Defined in:
lib/native_file_types/apple2/ShapeTable.rb

Instance Method Summary collapse

Instance Method Details

#draw_shape(canvas, shape_table, shape_number, x, y, colour) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/native_file_types/apple2/ShapeTable.rb', line 6

def draw_shape(canvas,shape_table,shape_number,x,y,colour)
	shape_pointer=shape_table[shape_number*2]+0x100*shape_table[1+shape_number*2]
	code_byte=shape_table[shape_pointer]
	shape_pointer+=1

	begin
		code_0=code_byte>>6
		code_1=(code_byte & 0b111000)>>3
		code_2=code_byte & 0b111
		
		if (code_0==0) then 
			if (code_1==0) then
				codes=[code_2]
			else
				codes=[code_2,code_1]
			end
		else
			codes=[code_2,code_1,code_0]
		end
		codes.each do |code|
			if (code>=4) && (!canvas.nil?) then
				canvas[x,y]=colour 
			end
			
			case (code % 4)
			when 0b00 then y-=1
			when 0b01 then x+=1
			when 0b10 then y+=1
			when 0b11 then x-=1
			end
		end
		
		code_byte=shape_table[shape_pointer]
		shape_pointer+=1	
	end	until code_byte==0 || code_byte.nil?
	[x,y]
end