|
Post by kram16384 on Jan 8, 2007 0:06:36 GMT -5
I just thought of how we can go object oriented with BASIEGAXORZ without using more than one heap.
lets just say classes, functions, and subs would be declared in asm.
example: sub do_something( integer d0, string d1, address a2) andi.w $3e, d0 move.l a2, a0 add.l d0, a0 move.b d1, 4(a0) end sub
function addtoval( integer d0, integer d1) returns integer as d2 add.w d1, d0 move.w d0, d2 end function
as for classes, they would be containers for functions and subs but cannot be declared public, private, or protected
classes define new data tyles and parsers and when applied to an object, set up heap space for the newly defined object, IN THE SAME HEAP AS EVERYTHING ELSE. if the class uses a memory region, then it is allocated to the object and any object can use it if statically set up, if an address register is used, then it is possible to have the object set up space st the preprocessor tells it. example:
;varlong variable1 ;stringsize 3 ;varstr var2
those are seen by the compiler and used to allocate space in the stack for an object within the same stack
functions would be called as any BASIC function would be called
member functions called as argunerics are
subs called like BASIC commands
member subs called like this:
dim a as new newobject a.sub1 "test", 3
Oompa Loompa I hope you see this post, and I wonder what you think of the idea.
|
|
oompa loompa
I AM THE GOVERNATOR
"Git 'Er Dun!"
Posts: 1,301
|
Post by oompa loompa on Jan 31, 2007 0:12:13 GMT -5
I already added subs+functions to my version of BasiEgaXorz. It does use the single heap to store values . I haven't looked at the source for a while (probably longer than a year) - so I dunno how buggy it is. When i get back into developing more for bex, i'll release that version out Darn, I think I even made a local/global variable thing for the subs+functions too. I think it uses more memory than it suppose to because it allocates those variables to static addresses, meaning the more variables you have in subs+functions, the more likely you'll run out of memory I dunno about classes though, I think classes are actually too advanced for basic programmers . Classes won't run very fast on the genesis btw because of all the data that needs to be processed in between classes
|
|
|
Post by Tom Maneiro on Feb 1, 2007 10:56:04 GMT -5
Classes...
Add the hell of data structures, ADTs, and such things to our small-brain Genesis sounds like you want to batte with your code.
I'm thinking on a thing that should be easier to implement than ADTs: UDTs (user-defined types). For example:
Type LicensePlate State as string * 1 Type as integer Serial as string * 7 End type
so you only do this:
Dim xy as LicensePlate xy.serial = "ABC 133" xy.type = TYPE_NORMAL
Is it possible?
|
|
oompa loompa
I AM THE GOVERNATOR
"Git 'Er Dun!"
Posts: 1,301
|
Post by oompa loompa on Feb 4, 2007 15:51:12 GMT -5
the only way i can think of making it work is binding variable names together and tricking the compiler , eg: when you do "Dim xy as LicensePlate", the compiler will create the variables for you automatically: xy.State$ (size = 7) xy.Type% xy.Serial$ (size = 7) but it sucks doing that in visual basic because i need to make another storage to hold user defined variable types i don't really see a good use for it in basic though, nobody's gonna script something that complicated , where user defined variables are crucial
|
|
|
Post by Tom Maneiro on Feb 4, 2007 19:57:31 GMT -5
UDTs are nice for handle long ammounts of fields. Think on a RPG: Type enemy Name as string * 64 Level as integer HP as long Attacks(4) as integer 'could be another UDT ...put a shitload of interesting fields there... End type ...so when you need a pack of enemies, you should only do this: Dim badniks(16) as enemy For i = 1 to 16 badnik(i) = RandomBadnik() Next instead of the subnormal way of declare 16*(fields_number) variables with 16*(fields_number) names and write a shitload of code that could be reduced. Think outside the box! Keyboards and fingers are not as good as they were 10 years ago.
|
|
oompa loompa
I AM THE GOVERNATOR
"Git 'Er Dun!"
Posts: 1,301
|
Post by oompa loompa on Feb 7, 2007 8:07:29 GMT -5
haha not going to happen with basiegaxorz's architecture, since it's more of a lower level language. you can do something like memcopy to accomplish the same thing i think games made for the genesis are very simple, so yea, go put your fingers to work . you don't really need to enter in a lot of code - basiegaxorz code can be optimized
|
|