2017-04-01 22:26:44 +01:00
|
|
|
## Copyright (C) 2016 Jeremiah Orians
|
2017-03-29 01:25:39 +01:00
|
|
|
## This file is part of stage0.
|
|
|
|
##
|
2018-08-27 02:50:34 +01:00
|
|
|
## stage0 is free software: you can redistribute it and/or modify
|
2017-03-29 01:25:39 +01:00
|
|
|
## it under the terms of the GNU General Public License as published by
|
|
|
|
## the Free Software Foundation, either version 3 of the License, or
|
|
|
|
## (at your option) any later version.
|
|
|
|
##
|
|
|
|
## stage0 is distributed in the hope that it will be useful,
|
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
## GNU General Public License for more details.
|
|
|
|
##
|
|
|
|
## You should have received a copy of the GNU General Public License
|
|
|
|
## along with stage0. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2016-07-21 03:07:10 +01:00
|
|
|
import os, os.path
|
|
|
|
import string
|
|
|
|
import array
|
|
|
|
import time
|
|
|
|
import cherrypy
|
|
|
|
import User_Interface as UI
|
2017-02-12 15:34:12 +00:00
|
|
|
import sys
|
2016-07-21 03:07:10 +01:00
|
|
|
|
|
|
|
class StringGenerator(object):
|
|
|
|
@cherrypy.expose
|
|
|
|
def index(self):
|
|
|
|
return UI.returnPage()
|
|
|
|
|
|
|
|
@cherrypy.expose
|
|
|
|
def Memory(self, col=8, row=8, value=0):
|
|
|
|
if 0 > int(col) or 0 > int(row):
|
|
|
|
return "Out of range"
|
|
|
|
if int(value, 16) > 255:
|
|
|
|
return "Too big"
|
2016-08-12 04:09:02 +01:00
|
|
|
UI.Set_Memory(int(col)+(int(row) * 16) + UI.Current_Page , int(value, 16))
|
2016-07-21 03:07:10 +01:00
|
|
|
return UI.returnPage()
|
|
|
|
|
|
|
|
@cherrypy.expose
|
|
|
|
def Register(self, Reg="", value=0):
|
2016-08-12 04:09:02 +01:00
|
|
|
UI.Set_Register(int(Reg[1:]), int(value, 16))
|
2016-07-21 03:07:10 +01:00
|
|
|
return UI.returnPage()
|
|
|
|
|
|
|
|
@cherrypy.expose
|
|
|
|
def RUN(self):
|
|
|
|
UI.Step_lilith()
|
|
|
|
if UI.Current_IP in UI.Watchpoints:
|
|
|
|
raise cherrypy.HTTPRedirect("/")
|
|
|
|
return UI.returnPage()
|
|
|
|
|
|
|
|
@cherrypy.expose
|
|
|
|
def STEP(self):
|
|
|
|
UI.Step_lilith()
|
|
|
|
return UI.returnPage()
|
|
|
|
|
|
|
|
@cherrypy.expose
|
|
|
|
def STOP(self):
|
2017-02-12 15:34:12 +00:00
|
|
|
print("Stopping after: " + str(UI.Count) + " Instructions" )
|
2016-07-21 03:07:10 +01:00
|
|
|
return UI.returnPage()
|
|
|
|
|
|
|
|
@cherrypy.expose
|
|
|
|
def RESET(self):
|
2016-08-12 01:18:53 +01:00
|
|
|
UI.Reset_lilith()
|
2016-07-21 03:07:10 +01:00
|
|
|
return UI.returnPage()
|
|
|
|
|
|
|
|
@cherrypy.expose
|
|
|
|
def DEBUG(self, Inst=""):
|
2017-12-17 01:48:38 +00:00
|
|
|
if int(Inst, 16) in UI.Watchpoints:
|
|
|
|
UI.Watchpoints.remove(int(Inst, 16))
|
|
|
|
print("Watchpoint Deleted: " + Inst)
|
|
|
|
else:
|
|
|
|
UI.Watchpoints.add(int(Inst, 16))
|
2016-07-21 03:07:10 +01:00
|
|
|
return UI.returnPage()
|
|
|
|
|
2016-08-12 01:18:53 +01:00
|
|
|
@cherrypy.expose
|
|
|
|
def PAGEDOWN(self):
|
|
|
|
UI.Current_Page = UI.Current_Page + 4096
|
|
|
|
return UI.returnPage()
|
|
|
|
|
|
|
|
@cherrypy.expose
|
|
|
|
def PAGEUP(self):
|
|
|
|
UI.Current_Page = UI.Current_Page - 4096
|
|
|
|
if 0 > UI.Current_Page:
|
|
|
|
UI.Current_Page = 0
|
|
|
|
return UI.returnPage()
|
|
|
|
|
2017-02-16 04:46:32 +00:00
|
|
|
@cherrypy.expose
|
|
|
|
def WINDOW(self, Window=0):
|
|
|
|
UI.Current_Page = int(Window, 16)
|
|
|
|
return UI.returnPage()
|
|
|
|
|
2016-08-21 01:36:56 +01:00
|
|
|
@cherrypy.expose
|
|
|
|
def SPEEDBREAKPOINT(self):
|
|
|
|
UI.Step_lilith()
|
|
|
|
while UI.Current_IP not in UI.Watchpoints:
|
|
|
|
UI.Step_lilith()
|
2017-02-12 22:25:03 +00:00
|
|
|
if UI.Count == UI.Debug_Point:
|
2017-02-12 15:34:12 +00:00
|
|
|
break
|
2016-08-21 01:36:56 +01:00
|
|
|
return UI.returnPage()
|
|
|
|
|
2016-07-21 03:07:10 +01:00
|
|
|
if __name__ == '__main__':
|
2017-02-12 15:34:12 +00:00
|
|
|
UI.main(sys.argv[1:])
|
2016-07-21 03:07:10 +01:00
|
|
|
conf = {
|
|
|
|
'/': {
|
|
|
|
'tools.sessions.on': True,
|
|
|
|
'tools.staticdir.root': os.path.abspath(os.getcwd())
|
|
|
|
},
|
|
|
|
'/generator': {
|
|
|
|
'request.dispatch': cherrypy.dispatch.MethodDispatcher(),
|
|
|
|
'tools.response_headers.on': True,
|
|
|
|
'tools.response_headers.headers': [('Content-Type', 'text/plain')],
|
|
|
|
},
|
|
|
|
'/static': {
|
|
|
|
'tools.staticdir.on': True,
|
|
|
|
'tools.staticdir.dir': './public'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
webapp = StringGenerator()
|
|
|
|
webapp.generator = StringGenerator()
|
|
|
|
cherrypy.quickstart(webapp, '/', conf)
|