Skip to content

Commit 7400e7e

Browse files
author
Marco Bakera
committed
init version of emulator written in godot.
1 parent 6f00714 commit 7400e7e

11 files changed

+264
-0
lines changed

godot_emu/Main.gd

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
extends Node2D
2+
3+
var width
4+
var height
5+
var tilemap
6+
var server
7+
8+
const PORT = 10101
9+
10+
const YELLOW = 49 # ascii 1
11+
12+
# Called when the node enters the scene tree for the first time.
13+
func _ready():
14+
tilemap = get_node("TileMap")
15+
update_width_height()
16+
clear_display()
17+
18+
print("listening on port ", PORT)
19+
server = TCP_Server.new()
20+
server.listen(PORT)
21+
22+
func clear_display():
23+
for x in range(width):
24+
for y in range(height):
25+
tilemap.set_cell(x, y, 0)
26+
27+
# Called every frame. 'delta' is the elapsed time since the previous frame.
28+
func _process(delta):
29+
if server.is_connection_available():
30+
print("conn available")
31+
var conn = server.take_connection()
32+
print("bytes available ", conn.get_available_bytes())
33+
var bs = conn.get_data(conn.get_available_bytes())
34+
print("bytes ", bs, len(bs))
35+
process_bytes(bs[1])
36+
37+
38+
func process_bytes(bytes):
39+
var x = 0
40+
var y = 0
41+
42+
for b in bytes:
43+
print("byte ", b)
44+
print("xy ", x, " ", y)
45+
46+
tilemap.set_cell(x, y, b == YELLOW)
47+
48+
x += 1
49+
if x >= width:
50+
x = 0
51+
y += 1
52+
53+
func _on_Button_pressed():
54+
var cell
55+
for x in range(4):
56+
cell = tilemap.get_cell(x, 0)
57+
print("x ", x, " cell ", cell,
58+
" type ", typeof(tilemap), " invalid ", cell == TileMap.INVALID_CELL)
59+
tilemap.set_cell(x, 2, cell)
60+
61+
func _on_teWidth_text_changed():
62+
update_width_height()
63+
64+
func _on_teHeight_text_changed():
65+
update_width_height()
66+
67+
func update_width_height():
68+
print("updating width and height")
69+
var tHeight = get_node("teHeight").text
70+
height = int(tHeight)
71+
var tWidth = get_node("teWidth").text
72+
width = int(tWidth)
73+
print(width, " ", height)
74+

godot_emu/Main.tres

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[gd_resource type="TileSet" load_steps=2 format=2]
2+
3+
[ext_resource path="res://rogueflip_tiles.jpg" type="Texture" id=1]
4+
5+
[resource]
6+
0/name = "rogueflip_tiles.jpg 0"
7+
0/texture = ExtResource( 1 )
8+
0/tex_offset = Vector2( 0, 0 )
9+
0/modulate = Color( 1, 1, 1, 1 )
10+
0/region = Rect2( 0, 0, 20, 20 )
11+
0/tile_mode = 0
12+
0/occluder_offset = Vector2( 0, 0 )
13+
0/navigation_offset = Vector2( 0, 0 )
14+
0/shapes = [ ]
15+
0/z_index = 0
16+
1/name = "rogueflip_tiles.jpg 1"
17+
1/texture = ExtResource( 1 )
18+
1/tex_offset = Vector2( 0, 0 )
19+
1/modulate = Color( 1, 1, 1, 1 )
20+
1/region = Rect2( 20, 0, 20, 20 )
21+
1/tile_mode = 0
22+
1/occluder_offset = Vector2( 0, 0 )
23+
1/navigation_offset = Vector2( 0, 0 )
24+
1/shapes = [ ]
25+
1/z_index = 0

godot_emu/Main.tscn

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[gd_scene load_steps=3 format=2]
2+
3+
[ext_resource path="res://Main.gd" type="Script" id=1]
4+
[ext_resource path="res://Main.tres" type="TileSet" id=2]
5+
6+
[node name="Main" type="Node2D"]
7+
script = ExtResource( 1 )
8+
9+
[node name="Button" type="Button" parent="."]
10+
margin_left = 6.0
11+
margin_top = 547.0
12+
margin_right = 122.0
13+
margin_bottom = 592.0
14+
15+
[node name="TileMap" type="TileMap" parent="."]
16+
scale = Vector2( 2, 2 )
17+
tile_set = ExtResource( 2 )
18+
cell_size = Vector2( 20, 20 )
19+
format = 1
20+
21+
[node name="teWidth" type="TextEdit" parent="."]
22+
margin_left = 135.0
23+
margin_top = 570.0
24+
margin_right = 165.0
25+
margin_bottom = 590.0
26+
text = "28"
27+
28+
[node name="teHeight" type="TextEdit" parent="."]
29+
margin_left = 187.0
30+
margin_top = 570.0
31+
margin_right = 217.0
32+
margin_bottom = 590.0
33+
text = "13"
34+
[connection signal="pressed" from="Button" to="." method="_on_Button_pressed"]
35+
[connection signal="text_changed" from="teWidth" to="." method="_on_teWidth_text_changed"]
36+
[connection signal="text_changed" from="teHeight" to="." method="_on_teHeight_text_changed"]

godot_emu/Map.gd

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
extends Node2D
2+
3+
# Declare member variables here. Examples:
4+
# var a = 2
5+
# var b = "text"
6+
7+
8+
# Called when the node enters the scene tree for the first time.
9+
func _ready():
10+
pass # Replace with function body.
11+
12+
# Called every frame. 'delta' is the elapsed time since the previous frame.
13+
#func _process(delta):
14+
# pass

godot_emu/Map.tscn

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[gd_scene load_steps=3 format=2]
2+
3+
[ext_resource path="res://Map.gd" type="Script" id=1]
4+
[ext_resource path="res://Main.tres" type="TileSet" id=2]
5+
6+
[node name="Map" type="Node2D"]
7+
script = ExtResource( 1 )
8+
9+
[node name="TileMap" type="TileMap" parent="."]
10+
tile_set = ExtResource( 2 )
11+
cell_size = Vector2( 20, 20 )
12+
format = 1

godot_emu/default_env.tres

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[gd_resource type="Environment" load_steps=2 format=2]
2+
3+
[sub_resource type="ProceduralSky" id=1]
4+
5+
[resource]
6+
background_mode = 2
7+
background_sky = SubResource( 1 )

godot_emu/icon.png

3.35 KB
Loading

godot_emu/icon.png.import

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="StreamTexture"
5+
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
6+
metadata={
7+
"vram_texture": false
8+
}
9+
10+
[deps]
11+
12+
source_file="res://icon.png"
13+
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
14+
15+
[params]
16+
17+
compress/mode=0
18+
compress/lossy_quality=0.7
19+
compress/hdr_mode=0
20+
compress/bptc_ldr=0
21+
compress/normal_map=0
22+
flags/repeat=0
23+
flags/filter=true
24+
flags/mipmaps=false
25+
flags/anisotropic=false
26+
flags/srgb=2
27+
process/fix_alpha_border=true
28+
process/premult_alpha=false
29+
process/HDR_as_SRGB=false
30+
process/invert_color=false
31+
stream=false
32+
size_limit=0
33+
detect_3d=true
34+
svg/scale=1.0

godot_emu/project.godot

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
; Engine configuration file.
2+
; It's best edited using the editor UI and not directly,
3+
; since the parameters that go here are not all obvious.
4+
;
5+
; Format:
6+
; [section] ; section goes between []
7+
; param=value ; assign values to parameters
8+
9+
config_version=4
10+
11+
_global_script_classes=[ ]
12+
_global_script_class_icons={
13+
14+
}
15+
16+
[application]
17+
18+
config/name="fffemulator"
19+
run/main_scene="res://Main.tscn"
20+
config/icon="res://icon.png"
21+
22+
[display]
23+
24+
window/size/width=800
25+
26+
[rendering]
27+
28+
environment/default_environment="res://default_env.tres"

godot_emu/rogueflip_tiles.jpg

30.2 KB
Loading

godot_emu/rogueflip_tiles.jpg.import

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="StreamTexture"
5+
path="res://.import/rogueflip_tiles.jpg-088dc7d316aa9d32853e0afcfc6ba17d.stex"
6+
metadata={
7+
"vram_texture": false
8+
}
9+
10+
[deps]
11+
12+
source_file="res://rogueflip_tiles.jpg"
13+
dest_files=[ "res://.import/rogueflip_tiles.jpg-088dc7d316aa9d32853e0afcfc6ba17d.stex" ]
14+
15+
[params]
16+
17+
compress/mode=0
18+
compress/lossy_quality=0.7
19+
compress/hdr_mode=0
20+
compress/bptc_ldr=0
21+
compress/normal_map=0
22+
flags/repeat=0
23+
flags/filter=true
24+
flags/mipmaps=false
25+
flags/anisotropic=false
26+
flags/srgb=2
27+
process/fix_alpha_border=true
28+
process/premult_alpha=false
29+
process/HDR_as_SRGB=false
30+
process/invert_color=false
31+
stream=false
32+
size_limit=0
33+
detect_3d=true
34+
svg/scale=1.0

0 commit comments

Comments
 (0)