-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
file viewer, midi player working, some ugly changes, buffered drawing…
… for faster blitting, graphing applications, new stable release!
- Loading branch information
Gabriel
committed
Jan 13, 2019
1 parent
7511fa1
commit 23e41f3
Showing
75 changed files
with
4,850 additions
and
2,954 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
cmake_minimum_required(VERSION 2.8) | ||
cmake_policy(SET CMP0054 NEW) | ||
cmake_policy(SET CMP0025 NEW) | ||
project(LA140_emulator) | ||
|
||
set(CMAKE_SUPPRESS_REGENERATION true) | ||
set (CMAKE_CXX_STANDARD 17) | ||
|
||
# call "brew install sdl2" | ||
|
||
if (ARM) | ||
include_directories("../os_library/include") | ||
endif() | ||
|
||
if (DESKTOP) | ||
find_package(SDL2 REQUIRED) | ||
include_directories(${SDL2_INCLUDE_DIRS}) | ||
include_directories("include/") | ||
|
||
file(GLOB main_src | ||
"source/sdlmain.cpp" | ||
"include/library.h" | ||
) | ||
|
||
file(GLOB bios_src | ||
"source/bios/*.cpp" | ||
"source/bios/*.h" | ||
) | ||
|
||
file(GLOB framework_src | ||
"source/framework/*.cpp" | ||
"source/framework/*.h" | ||
) | ||
|
||
file(GLOB gui_src | ||
"source/gui/*.cpp" | ||
"source/gui/*.h" | ||
) | ||
endif() | ||
|
||
if (ARM) | ||
file(GLOB main_src | ||
"../os_host/source/framework/Wnd.cpp" | ||
) | ||
|
||
file(GLOB linker_script | ||
"../apps/test34_scope/app.lds" | ||
) | ||
endif() | ||
|
||
file(GLOB application_src | ||
"../apps/test34_scope/*.cpp" | ||
"../apps/test34_scope/*.h" | ||
) | ||
|
||
file(GLOB application_graph_src | ||
"../apps/test34_scope/graph/*.cpp" | ||
"../apps/test34_scope/graph/*.h" | ||
) | ||
|
||
file(GLOB application_sensor_src | ||
"../apps/test34_scope/sensor/*.cpp" | ||
"../apps/test34_scope/sensor/*.h" | ||
) | ||
|
||
if (DESKTOP) | ||
source_group("source\\main" FILES "source/sdlmain.cpp") | ||
source_group("source\\bios" FILES ${bios_src}) | ||
source_group("source\\framework" FILES ${framework_src}) | ||
source_group("source\\gui" FILES ${gui_src}) | ||
endif() | ||
|
||
source_group("application" FILES ${application_src}) | ||
source_group("application\\graph" FILES ${application_graph_src}) | ||
source_group("application\\sensor" FILES ${application_sensor_src}) | ||
source_group("include" FILES "include/library.h") | ||
|
||
add_executable(application ${main_src} ${bios_src} ${framework_src} ${gui_src} ${application_src} ${application_graph_src} ${application_sensor_src}) | ||
|
||
if (ARM) | ||
target_link_libraries(application m) | ||
target_link_libraries(application bios) | ||
set_target_properties(application PROPERTIES LINK_DEPENDS ${linker_script}) | ||
set_target_properties(application PROPERTIES LINK_FLAGS "-T ${linker_script}") | ||
endif() | ||
|
||
target_link_libraries(application ${SDL2_LIBRARIES}) | ||
|
||
install(TARGETS application DESTINATION bin) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
MEMORY | ||
{ | ||
rom (rx) : ORIGIN = 0x08020000, LENGTH = 20K | ||
ram (rwx) : ORIGIN = 0x20007000, LENGTH = 8K | ||
null (rwx): ORIGIN = 0x00001000, LENGTH = 4K | ||
} | ||
|
||
/* _estack = ORIGIN(ram)+LENGTH(ram)-0x100; */ | ||
|
||
SECTIONS | ||
{ | ||
.text : { | ||
*(.entry) | ||
*(.text*) /* Program code */ | ||
*(.rodata*) /* Read only data */ | ||
} >rom | ||
|
||
.data : { | ||
*(.data) /* Data memory */ | ||
} >ram AT >rom | ||
|
||
.bss : { | ||
*(.bss*) /* Zero-filled run time allocate data memory */ | ||
} >ram | ||
|
||
.rel.plt : { *(.rel.plt) } > rom | ||
.plt : { *(.plt) } > rom | ||
.got : { *(.got.plt) *(.got) } > ram /* relocation fixed by memory write! */ | ||
.dynsym : { *(.dynsym) } > null | ||
.dynstr : { *(.dynstr) } > null | ||
|
||
} | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads | ||
|
||
export PATH="/Users/gabrielvalky/Downloads/gcc-arm-none-eabi-7-2018-q2-update/bin/":"$PATH" | ||
mkdir -p build | ||
cd build | ||
|
||
arm-none-eabi-g++ -Wall -Os -Werror -fno-common -mcpu=cortex-m3 -mthumb -msoft-float -fno-exceptions -fno-rtti -fno-threadsafe-statics -Wno-psabi -MD -c ../main.cpp ../../../os_host/source/framework/Wnd.cpp -I../../../os_library/include/ | ||
#arm-none-eabi-gcc -fPIC -mcpu=cortex-m3 -mthumb -o output.elf -nostartfiles -Wl,--unresolved-symbols=ignore-all -T ../app.lds ./main.o | ||
arm-none-eabi-gcc -fPIC -mcpu=cortex-m3 -mthumb -o output.elf -nostartfiles -T ../app.lds ./main.o ./Wnd.o -lbios -lm -L../../../os_library/build | ||
|
||
arm-none-eabi-objdump -d -S output.elf > output.asm | ||
|
||
find . -type f -name '*.o' -delete | ||
find . -type f -name '*.d' -delete | ||
|
||
../../../../tools/elfstrip/elfstrip output.elf 34scope.elf |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mkdir fs | ||
sudo mount -t msdos /dev/disk2 fs | ||
cp build/34scope.elf fs/34scope.elf | ||
sudo umount fs | ||
rmdir fs |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
class CXAxis : public CWnd | ||
{ | ||
friend class CYAxis; | ||
|
||
protected: | ||
static int nicenumber(int n) | ||
{ | ||
int mantisa = n, exponent = 1; | ||
while (mantisa > 10) | ||
{ | ||
exponent *= 10; | ||
mantisa /= 10; | ||
} | ||
|
||
if (mantisa >= 5) | ||
mantisa = 5; | ||
else | ||
if (mantisa >= 2) | ||
mantisa = 2; | ||
else | ||
mantisa = 1; | ||
|
||
return mantisa * exponent; | ||
} | ||
|
||
virtual void FormatNumber(char* buf, int i) | ||
{ | ||
if (i<1000) | ||
{ | ||
sprintf(buf, "%d", i); | ||
return; | ||
} | ||
|
||
if (i<1000000) | ||
{ | ||
sprintf(buf, "%dk", i/1000); | ||
return; | ||
} | ||
|
||
sprintf(buf, "%dM", i/1000000); | ||
} | ||
|
||
virtual int reconstruct(int i) | ||
{ | ||
return i; | ||
} | ||
|
||
virtual void Redraw(int value, int origValue) | ||
{ | ||
int step = nicenumber(value/2); | ||
//BIOS::DBG::Print("orig=%d max=%d step=%d\n", origValue, value, step); | ||
CRect rcDeflated(m_rcClient); | ||
rcDeflated.Deflate(2, 0, 2, 0); | ||
BIOS::LCD::Bar(rcDeflated, RGB565(b0b0b0)); | ||
|
||
for (int _i=0; _i<=value; _i += step) | ||
{ | ||
int i = reconstruct(_i); | ||
if (i>origValue) | ||
break; | ||
|
||
int x = m_rcClient.left + m_rcClient.Width()*i/origValue; | ||
char formatted[16]; | ||
FormatNumber(formatted, _i); | ||
int width = strlen(formatted)*8; | ||
|
||
int tx = x; | ||
if (tx - width/2 < rcDeflated.left) | ||
tx = m_rcClient.left + 2 + width/2; | ||
|
||
if (tx-width/2+width > rcDeflated.right) | ||
tx = m_rcClient.right - 2 - width/2; | ||
|
||
BIOS::LCD::Print(tx - width/2, m_rcClient.bottom-14, RGB565(404040), RGB565(b0b0b0), formatted); | ||
|
||
if (x >= rcDeflated.left && x < rcDeflated.right) | ||
BIOS::LCD::Bar(x, m_rcClient.top, x+1, m_rcClient.top+3, RGB565(ffffff)); | ||
} | ||
} | ||
|
||
public: | ||
virtual void Update(int value) | ||
{ | ||
Redraw(value, value); | ||
} | ||
}; | ||
|
||
class CYAxis : public CWnd | ||
{ | ||
Range mRange; | ||
|
||
protected: | ||
virtual int forward(int i) | ||
{ | ||
return i; | ||
} | ||
|
||
virtual int backward(int i) | ||
{ | ||
return i; | ||
} | ||
|
||
virtual void FormatNumber(char* buf, int i) | ||
{ | ||
sprintf(buf, "%d", i); | ||
} | ||
|
||
public: | ||
virtual void OnPaint() | ||
{ | ||
} | ||
|
||
void Update(const Range& range) | ||
{ | ||
if (mRange == range) | ||
return; | ||
mRange = range; | ||
|
||
BIOS::LCD::Bar(m_rcClient, RGB565(b0b0b0)); | ||
|
||
auto drawTick = [&](int i) | ||
{ | ||
int y = m_rcClient.bottom - (backward(i)-range.mMin)*m_rcClient.Height()/(range.mMax-range.mMin); | ||
if (y < m_rcClient.bottom) | ||
BIOS::LCD::Bar(m_rcClient.right-2, y, m_rcClient.right, y+1, RGB565(ffffff)); | ||
|
||
char buffer[16]; | ||
FormatNumber(buffer, i); | ||
|
||
int ty = y-6; | ||
if (ty<m_rcClient.top) | ||
ty = m_rcClient.top; | ||
if (ty+14>m_rcClient.bottom) | ||
ty = m_rcClient.bottom-14; | ||
|
||
BIOS::LCD::Print(m_rcClient.right - strlen(buffer)*8-3, ty, RGB565(404040), RGB565(b0b0b0), buffer); | ||
}; | ||
|
||
int rangeMaxModified = forward(range.mMax/2); | ||
int step = CXAxis::nicenumber(rangeMaxModified); | ||
int total = std::max<>(forward(range.mMax), forward(-range.mMin)); | ||
|
||
for (int i=0; i<total; i += step) | ||
{ | ||
if (i < range.mMax) | ||
drawTick(i); | ||
// if (i > 0 && -i > range.mMin) | ||
// drawTick(-i); | ||
} | ||
} | ||
}; | ||
|
Oops, something went wrong.